home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
569
/
abzmon_s
/
abzmon.s
Wrap
Text File
|
1991-10-19
|
102KB
|
3,760 lines
**** ABZMON, V1.1, by Alain Birtz, april 22, 1987
**** ABZMON is public domain, it can be copied and distribued freely
.text
bios equ 13
xbios equ 14
gemdos equ 1
tab equ 9 * ascii tab code
spc equ $20 * ascii space code
comma equ 44 * ascii comma code
mnemo equ 42
ret_key equ $610000 * undo key
*------------------------------------------------------------------------------*
* Release free memory not used by the monitor program
move.l a7,a0 * save stack pointer
move.l #mon_stk,a7 * set monitor stack
move.l 4(a0),a0 * basepage address
move.l $c(a0),d0 * prg length
add.l $14(a0),d0 * data area length
add.l $1c(a0),d0 * bss area length
add.l #$100,d0 * reserve $100 long base page
bsr Mshrink * release
*------------------------------------------------------------------------------*
clr.l -(sp) * enter in supervisor mode
move.w #$20,-(sp)
trap #gemdos
addq.l #6,sp
move.l d0,sv_ssp
bsr excep_new * initialise exeption vector
lea intro_s,a0 * intoduction string
bsr prt_str
move.l #over,-(sp) * stop walkback! (in monitor stack)
move.l sp,mon_sp * save monitor stack pointer
move.l #over,prg_stk * stop walkback! (in program stack)
move.l #prg_stk-4,prg_sp * set program stack pointer
sel_0 clr.b wait_fg * reset pause flag
lea main_s,a0 * print main option
bsr select
tst.b d0 * default ?
bne sel0_sv
moveq #'D',d0 * defautl is disassembler
clr.b indev * no default on input, output device
clr.b outdev
sel0_sv move.b d0,op_main * save main option
cmpi.b #'D',d0 * disassembler ?
beq sel_D
cmpi.b #'T',d0 * trace ?
beq sel_T
cmpi.b #'H',d0 * hexa editor ?
beq sel_H
cmpi.b #'S',d0 * search ?
beq sel_S
cmpi.b #'F',d0 * free memory ?
beq sel_F
cmpi.b #'M',d0 * move data ?
beq sel_M
cmpi.b #'L',d0 * load program ?
beq sel_L
cmpi.b #'B',d0 * set break point ?
beq sel_B
cmpi.b #'G',d0 * (Go) run program ?
beq sel_G
cmpi.b #'R',d0 * change register value ?
beq sel_R
cmpi.b #'C',d0 * change CCR value ?
beq sel_C
cmpi.b #'I',d0 * display data and prg info ?
beq sel_I
cmpi.b #'E',d0 * Exit
beq out
bra sel_0
exit: * local exit
tst.w ihandle * input file openned ?
beq exit2
move.w ihandle,d0 * yes, close it
bsr close
clr.w ihandle
exit2 cmpi.w #3,ohandle * output file openned ?
bls exit3
lea n_line,a0 * yes, write new line
move.l #2,d0 * number of char to output
move.w ohandle,d1 * output file handle
bsr write * write string
move.w ohandle,d0 * and close the file
bsr close
clr.w ohandle
exit3 move.l mon_sp,sp * restore monitor stack pointer
bra sel_0
out: * return to parent process
bsr excep_old * restore exception vector
move.l sv_ssp,-(sp) * exit supervisor mode
move.w #$20,-(sp)
trap #gemdos
addq.l #6,sp
lea bye_s,a0
bsr prt_str
clr.w -(sp)
trap #gemdos * Pterm0
rts
over: andi #$7fff,SR * clear trace bit
lea over_s,a0 * 'walkback over stack'
bsr prt_str
bra out
*------------------------------------------------------------------------------*
*--------------------------- Load program routine -----------------------------*
*------------------------------------------------------------------------------*
sel_L: move.b 'P',indev
bsr p_input * load but not execute
bra exit
*------------------------------------------------------------------------------*
*---------------------------- Break point routine -----------------------------*
*------------------------------------------------------------------------------*
sel_B: move.l $a0,svtrap8 * save old (trap #8) vector
move.l #break_rout,$a0 * set new vector
sel_B_ lea break_s,a0 * break point address ?
bsr prt_str
bsr get_a5 * get value
tst.b nil_val * no default here
bne sel_B_
move.l a5,brkadr * save address
move.w (a5),brkcode * save instr. code
move.w #$4e48,(a5) * change instr. code by trap #8 code
lea brkno_s,a0 * how many time ?
bsr prt_str
bsr get_a5 * get value
tst.b nil_val * default value is 1 time
bne sel_B_0
subq.l #1,a5
sel_B_0 move.l a5,brkno * save number
move.l #single_step,$24 * set single step (trace) vector
bra exit
*------------------------------------------------------------------------------*
break_rout: * break (trap #8) routine
move SR,saveCCR * save CCR
movem.l d0-d7/a0-a7,regs * save register
addq.l #6,regs+60 * a7 before exeption
movea.l brkadr,a5 * address of break point
move.w brkcode,(a5) * restore instr. code
tst.l brkno * last time to do the break point ?
bne break_cont * if no, do another break point
move.l sp,prg_sp * save program stack pointer
addq.l #6,prg_sp
bra break_exit
*------------------------------------------------------------------------------*
break_cont: * do another break point
subq.l #1,brkno * update counter
move.l brkadr,2(sp) * address to be single stepped
movem.l regs,d0-d7/a0-a6 * restore register
ori #$8000,(sp) * set trace bit
rte * execute brkadr instruction
*------------------------------------------------------------------------------*
break_exit: * show register, CCR and exit
lea n_line,a0 * new line
bsr prt_str
bsr rev_on * enter reverse video mode
bsr disp_CCR * fill s_CCR with a5 adr. and codeCCR
lea s_CCR,a0
bsr prt_str * show address and status
bsr rev_off * exit reverse video mode
lea str,a3
bsr reg_disp * register info
lea str,a0
bsr prt_str * show register
move.l brkadr,cur_adr * become current adr.
move.l svtrap8,$a0 * restore old (trap #8) vector
bra exit
*------------------------------------------------------------------------------*
single_step: * after execution of the brkadr instr.
movem.l a5,-(sp) * save register
movea.l brkadr,a5 * address of break point
move.w #$4e48,(a5) * change instr. code by trap #8 code
movem.l (sp)+,a5 * restore register
andi #$7fff,(sp) * clear trace bit
rte * continue the (ipname) program
*------------------------------------------------------------------------------*
*---------------------------- Run program routine -----------------------------*
*------------------------------------------------------------------------------*
sel_G: * NB: not breakpoint, exit monitor prg
lea adr_1st,a0 * start address
bsr prt_str
bsr get_a5 * get value
lea n_line,a0 * new line
bsr prt_str
tst.b nil_val * no value ?
bne sel_G_0 * give default parameter
move.l a5,cur_adr * a5 address become current adr.
sel_G_0 move.l prg_sp,sp * change monitor stack for prg stack
move.l cur_adr,-(sp) * current adr. on stack
move saveCCR,CCR * current prg. CCR
movem.l regs,d0-d7/a0-a6 * current register
rts * jump to cur_adr
*------------------------------------------------------------------------------*
*------------------------- change regs value routine --------------------------*
*------------------------------------------------------------------------------*
sel_R: lea str,a3 * output string
move.b #27,(a3)+ * enter reverse video mode
move.b #'p',(a3)+
bsr reg_disp * value in regs to ascii
lea str,a0
bsr prt_str * display actual register
lea R_s,a0 * initial position on screen
bsr prt_str
moveq #0,d3 * initial relative cursor position
* relative position are 0-7 for D0, 8-15 for D1, ... , 56-63 for D7
* 64-71 for A0, ... , 120-127 for A7.
loop_R bsr ch_input * read one char
cmpi.l #$500000,d0 * down key ?
beq R_down * go one line down
cmpi.l #$480000,d0 * up key ?
beq R_up * go one line up
cmpi.l #$4b0000,d0 * left key ?
beq R_left * go left one char
cmpi.l #$4d0000,d0 * right key ?
beq R_right * go right one char
cmpi.l #ret_key,d0 * exit key ?
beq R_ex * exit R_loop
cmpi.b #'V',d0 * down key ?
beq R_down * go one line down
cmpi.b #'U',d0 * up key ?
beq R_up * go one line up
cmpi.b #'L',d0 * left key ?
beq R_left * go left one char
cmpi.b #'R',d0 * right key ?
beq R_right * go right one char
cmpi.b #'Q',d0 * exit key ?
beq R_ex * exit R_loop
cmpi.b #'v',d0 * down key ?
beq R_down * go one line down
cmpi.b #'u',d0 * up key ?
beq R_up * go one line up
cmpi.b #'l',d0 * left key ?
beq R_left * go left one char
cmpi.b #'r',d0 * right key ?
beq R_right * go right one char
cmpi.b #'q',d0 * exit key ?
beq R_ex * exit R_loop
bsr asc_hx * hexa char ?
bvc R_hex * yes, change the register value
bra loop_R
R_ex move.l regs+60,prg_sp * save new prg stack pointer
lea R_ex_s,a0 * exit video mode
bsr prt_str
bra exit
*------------------------------------------------------------------------------*
R_down cmpi.b #64,d3 * second line ?
bcc loop_R * do nothing
addi.b #64,d3 * update relative position
lea down_s,a0 * move cursor down
bsr prt_str
bra loop_R
*------------------------------------------------------------------------------*
R_up cmpi.b #64,d3 * first line ?
bcs loop_R * do nothing
subi.b #64,d3 * update relative position
lea up_s,a0 * move cursor up
bsr prt_str
bra loop_R
*------------------------------------------------------------------------------*
R_left tst.b d3 * first positon of first line ?
beq loop_R * do nothing
cmpi.b #64,d3 * first positon of second line ?
beq loop_R * do nothing
move.b d3,d0 * now find relative position modulo 8
andi.b #7,d0
bne R_l_1 * if not at the 1st hexa digit, 1 left
lea left_s,a0 * else move 2 left
bsr prt_str
R_l_1 lea left_s,a0 * move cursor left
bsr prt_str
subq.b #1,d3 * update relative position
bra loop_R
*------------------------------------------------------------------------------*
R_right cmpi.b #63,d3 * last positon of first line ?
beq loop_R * do nothing
cmpi.b #127,d3 * last positon of second line ?
beq loop_R * do nothing
addq.b #1,d3 * update relative position
move.b d3,d0 * now find relative position modulo 8
andi.b #7,d0
bne R_r_1 * if not at the last hexa digit, only 1
lea right_s,a0 * else move 2 right
bsr prt_str
R_r_1 lea right_s,a0 * move cursor right
bsr prt_str
bra loop_R
*------------------------------------------------------------------------------*
R_hex move.w d3,d1 * find byte no of the current nibble
andi.w #7,d1 * no -> (7 & d3)/2
lsr.w #1,d1
move.w d3,d2 * and register no
lsr.w #3,d2
andi.w #15,d2
lsl.w #2,d2 * offset in regs
add.w d1,d2
lea regs,a0
adda.w d2,a0 * current register in regs
move.b (a0),d1 * now split lo and hi part of the byte
move.b d0,d2
btst #0,d3 * high or low nibble ?
beq R_hi
andi.b #$f0,d1 * clear lo part of regs
bra R_add
R_hi lsl.b #4,d2 * hex digit to high part
andi.b #$f,d1 * clear high part of regs byte
R_add add.b d1,d2 * add lo and hi part
move.b d2,(a0) * back to regs
addi.b #'0',d0 * print hexa digit
cmpi.b #'9',d0
bls R_prt
addq.b #7,d0
R_prt lea R_chr_s,a0 * print char, cursor left
move.b d0,(a0)
bsr prt_str
bra R_right * if possible one step
*------------------------------------------------------------------------------*
*---------------------- prg and data file info routine ------------------------*
*------------------------------------------------------------------------------*
sel_I: lea data_s,a0 * DATA FILE:
bsr prt_str
lea idname,a0 * filename
bsr prt_str
lea from_s,a0 * display data file info
bsr prt_str
lea prg_s,a0 * PRG FILE:
bsr prt_str
lea ipname,a0 * filename
bsr prt_str
move.l cur_adr,d2 * current adr.
lea c_p_a_s+20,a0
bsr d2_hx_l * adr to hex
lea c_p_a_s,a0 * print hex value
bsr prt_str
lea b_pg_s,a0 * display prg file info
bsr prt_str
bra exit
*------------------------------------------------------------------------------*
*-------------------------- change CCR value routine --------------------------*
*------------------------------------------------------------------------------*
sel_C: lea newCCRs,a0 * what new value
bsr prt_str
bsr get_a5 * get value
tst.b nil_val * no value, don't change any thing
bne sel_C_x
move.w a5,saveCCR
sel_C_x bra exit
*------------------------------------------------------------------------------*
*---------------------------- Free memory routine -----------------------------*
*------------------------------------------------------------------------------*
sel_F: moveq #-1,d0 * get free space
bsr Malloc
move.l d0,d2 * show free memory
lea free_s+15,a0
bsr d2_hx_l
lea free_s,a0
bsr prt_str
bsr get_a5 * get needed memory
tst.b nil_val * no value ?
bne exit
movea.l a5,a4 * save value
move.l a5,d0 * reserve space
beq exit * if zero, return
bsr Malloc
movea.l d0,a5 * start address
adda.l a5,a4 * end address
bsr Data_info * show both address
bra exit
*------------------------------------------------------------------------------*
*----------------------------- Move data routine ------------------------------*
*------------------------------------------------------------------------------*
sel_M: lea s_move,a0
bsr select * choice...
tst.b d0 * default ?
beq f_mem * default is no 1
cmpi.b #'0',d0 * Exit
beq exit
cmpi.b #'1',d0 * file to memory
beq f_mem
cmpi.b #'2',d0 * memory to file
beq mem_f
cmpi.b #'3',d0 * memory to memory
beq mem_m
bra sel_M
*------------------------------------------------------------------------------*
f_mem: lea idname,a0 * input data filename
bsr getname * pathname or filename
bsr getsize * size of the file
f_mem_ lea adr_1st,a0 * start address
bsr prt_str
bsr get_a5 * get value
tst.b nil_val * no default here
bne f_mem_
lea idname,a0 * input data filename
bsr open * open file
bsr read * read file
bsr Data_info * display start and end address
bra exit
*------------------------------------------------------------------------------*
mem_f: bsr m_input * start and end address
bsr create * create the destination file
move.l save1st,a0 * beggining of write buffer
move.l saveend,d0
sub.l a0,d0 * buffer length
addq.l #1,d0
move.w ohandle,d1 * output file handle
bsr write * do the file and exit
bra exit
*------------------------------------------------------------------------------*
mem_m: lea src_s,a0 * SOURCE
bsr prt_str
bsr m_input * start and end address of source
lea n_line,a0 * new line
bsr prt_str
movea.l a5,a3 * save start address
lea dest_s,a0 * DESTINATION
bsr prt_str
mem_m_ lea adr_1st,a0 * start address of destination
bsr prt_str
bsr get_a5 * get value
tst.b nil_val * no default here
bne mem_m_
lea n_line,a0 * new line
bsr prt_str
mem_m_l move.b (a3)+,(a5)+ * move data loop
cmpa.l a3,a4
bge mem_m_l
bra exit
*------------------------------------------------------------------------------*
*--------------------------- Search main routine ------------------------------*
*------------------------------------------------------------------------------*
sel_S: bsr outputf * get output
bsr inputf * get input device
clr.b srch_fg * initialise found flag
sel_S_ lea srch_s,a0 * Ascii string or Byte string
bsr select
tst.b d0 * default ?
beq srch_a * default is ascii
cmpi.b #'A',d0 * Ascii
beq srch_a
cmpi.b #'B',d0 * Byte
beq srch_b
cmpi.b #'E',d0 * Exit
beq exit
bra sel_S_
*------------------------------------------------------------------------------*
srch_a lea ascii_s,a0 * get search string
bsr prt_str
lea srchstr,a0 * read search string
moveq #20,d0 * 20 char maximum
bsr read_str
lea srchstr,a0 * here, do the wildcard string
lea wildstr,a3
a_wild tst.b (a0) * end of string ?
beq a_ready * yes, ready to search
cmpi.b #'?',(a0)+ * wildcard symbol ?
seq (a3)+ * if yes set, else clr
bra a_wild
a_ready move.l a0,d0
subi.l #srchstr,d0 * string length
lea srchstr,a0 * ready to search
cmpi.b #2,d0
bcs exit * need minimum 2 char
movea.l save1st,a1
movea.l saveend,a2
lea wildstr,a3
a_find bsr nx_find
move.l srchreg,d3 * byte number
andi.w #$ff,d3 * only byte part
subq.w #1,d3 * counter
lea str+33,a0 * output string
ascopy move.b (a1)+,d0 * ascii representation
cmpi.b #' ',d0
bcs a_dot * only char >= 32 or <127
cmpi.b #127,d0
bhi a_dot
bra a_ok
a_dot moveq #'.',d0
a_ok move.b d0,(a0)+
dbra d3,ascopy
clr.b (a0) * null terminate string
cmpi.b #'S',outdev * Screen ?
bne a_not_S
bsr S_srch
bra a_cont
a_not_S bsr F_srch * file: printer or disk
a_cont movem.l srchreg,d0/a0-a4 * restore register
addq.l #1,a1
bra a_find * loop
*------------------------------------------------------------------------------*
srch_b lea byte_s,a0 * get search string
bsr prt_str
lea str,a0 * read search string
moveq #60,d0 * 60 char maximum
bsr read_str
lea srchstr,a0 * here, do the wildcard string
lea str,a1
lea wildstr,a3
b_wild move.b (a1)+,d0 * end of string ?
beq b_ready * yes, ready to search
cmpi.b #' ',d0
beq b_wild * skip white space
cmpi.b #'?',d0 * wildcard symbol ?
bne b_hexa * no, keep hexa value
st (a3)+ * if yes set
addq.l #1,a0 * next char in srchstr
bra b_wild
b_hexa bsr asc_hx * hi nibble value
bvs srch_b * no hexa value, retry
lsl.b #4,d0 * multiply by 16
move.b d0,(a0) * and store
move.b (a1)+,d0 * next char
bsr asc_hx * lo nibble value
bvs srch_b * no hexa value, retry
add.b d0,(a0)+ * add tp previous value
sf (a3)+ * not wildcard byte
bra b_wild
b_ready move.l a0,d0
subi.l #srchstr,d0 * string length
cmpi.b #2,d0
bcs exit * need minimum 2 char
lea srchstr,a0 * ready to search
movea.l save1st,a1
movea.l saveend,a2
lea wildstr,a3
b_find bsr nx_find
move.l srchreg,d3 * byte number
andi.w #$ff,d3 * only byte part
subq.w #1,d3 * counter
lea str+33,a0 * output string
b_byte move.b (a1)+,d2 * byte value
bsr d2_hx_b * byte representation
addq.l #2,a0
move.b #' ',(a0)+
dbra d3,b_byte
clr.b -1(a0)
cmpi.b #'S',outdev * Screen ?
bne b_not_S
bsr S_srch
bra b_cont
b_not_S bsr F_srch * file: printer or disk
b_cont movem.l srchreg,d0/a0-a4 * restore register
addq.l #1,a1
bra b_find * loop
*------------------------------------------------------------------------------*
nx_find bsr find
cmpa.l a2,a1 * greather than end address ?
bgt srch_ex
st srch_fg * 'I have found something' flag
movem.l d0/a0-a4,srchreg * save register
lea str,a3 * output string
move.l a1,d2 * actual address in memory
cmpi.b #'D',indev * input device: Data file ?
bne nx_f_mp * or Memory or Prg file
sub.l save1st,d2 * file offset
lea fileoff,a0 * found at file offset $
bra nx_f_2
nx_f_mp lea found_s,a0 * found at memory adr. $
nx_f_2 bsr copy_s
lea str+24,a0
bsr d2_hx_l * found address
move.b #' ',str+32
rts
srch_ex tst.b srch_fg * find something ?
bne find_ex
lea notfind,a0 * sorry...
bsr prt_str
bsr ch_input
bra exit
find_ex lea n_line,a0 * new line
find_2 bsr prt_str
bra exit
*------------------------------------------------------------------------------*
find * search for a string in memory
* a0 is the address the string, d0 is length
* a1 the start address for the search and
* a2 the end adddress
* a3 is the address of the wildcard string
* '0' mean no widcard, '1' mean wildcard
* a3 and a1 are associated byte to byte
* and wildcard string must always begin by '0'
* To return
* a1 is the address of the first occurence or
* a2 + 1 if the string is not found
* other register not affected
movem.l d0-d3/a0/a2,-(sp)
subq.b #1,d0
move.b (a0),d3 * first char of the string
nx_mem clr.w d1 * char counter
chr_1st cmpa.l a2,a1
bgt fd_exit
cmp.b (a1)+,d3
bne chr_1st
nx_chr addq.b #1,d1 * if first char match, try next
tst.b 0(a3,d1.w) * wildcard?
bne no_test * if yes, don't do the next test
move.b 0(a0,d1.w),d2
cmp.b -1(a1,d1.w),d2
bne nx_mem * if second char not match
no_test cmp.b d0,d1
bne nx_chr * try until incomplete string
subq.l #1,a1
fd_exit movem.l (sp)+,d0-d3/a0/a2
rts
*------------------------------------------------------------------------------*
S_srch lea str,a0
bsr prt_str * show
bsr ch_input * and wait
cmpi.l #ret_key,d0 * loop until exit key
beq exit
cmpi.b #'Q',d0
beq exit
cmpi.b #'q',d0
beq exit
rts
*------------------------------------------------------------------------------*
F_srch lea str,a0 * write buffer
moveq #-1,d0 * count string length
F_count addq.l #1,d0
tst.b (a0)+
bne F_count * d0 is the number of char to output
move.w ohandle,d1 * output file handle
lea str,a0 * output string
bra write * write string
*------------------------------------------------------------------------------*
*------------------------- Hexa editor main routine ---------------------------*
*------------------------------------------------------------------------------*
sel_H: bsr outputf * get output
bsr inputf * get input
cmpi.b #'S',outdev * Screen ?
beq S_ed
bsr ed_line * printer or file
bra exit
S_ed clr.b altd_fg * clear altered flag
bsr ed_init * initialise with white space
suba.l #16,a5
bsr down * go to user
bsr altered * file is modified ? save ?
bra exit
*------------------------------------------------------------------------------*
ed_line bsr ed_init * initialise with white space
lea str+79,a0
move.b #13,(a0) * plus carriage return
move.b #10,(a0)+ * plus line feed
ed_lp cmpa.l a5,a4 * while start address < end address
bcs ed_ret * (return)
bsr adr_hx * address to hexadecimal ascii
bsr infbyte * byte to hexa value and char ascii
moveq #15,d1 * counter. change non printable by dot
lea str+62,a0 * beggining of the ascii representation
dotloop move.b (a0),d0 * the char to print
cmpi.b #32,d0 * test for printable char
bcs do_dot
cmpi.b #127,d0
bcs dotnext
do_dot move.b #'.',(a0) * replace by a dot
dotnext addq.w #1,a0
dbra d1,dotloop
lea str,a0 * write buffer
moveq #80,d0 * number of char to output
move.w ohandle,d1 * output file handle
bsr write * write string
adda.l #16,a5 * ready for next line
bra ed_lp
*------------------------------------------------------------------------------*
ed_init moveq #79,d0 * initialise the ascii str
lea str,a0
init_s move.b #' ',(a0)+
dbra d0,init_s
ed_ret rts
*------------------------------------------------------------------------------*
infbyte: * byte hexa value and ascii char
lea str+13,a0 * hexa bytes area
lea str+62,a1 * ascii representation area
moveq #15,d1 * counter
movem.l a5,-(sp) * save a5
do_inf move.b (a5)+,d0 * pick byte
bne cdiff0 * non null char ?
move.b #46,(a1)+ * if non, use '.' instead
bra infcont
cdiff0 move.b d0,(a1)+ * char representation
infcont move.b d0,-(sp) * save d0
lsr.b #4,d0 * high nibble
bsr nibble * conversion
move.b d0,(a0)+ * store the value
move.b (sp)+,d0 * restore d0
andi.b #$F,d0 * low nibble
bsr nibble * conversion
move.b d0,(a0)+ * store the value
addq.l #1,a0 * pass over one space
dbra d1,do_inf * loop until d1 > -1
movem.l (sp)+,a5 * restore a5
rts
nibble addi.b #48,d0 * ascii digit
cmpi.b #57,d0 * > 9 ?
bgt nodigit * no, it is a letter
rts
nodigit addq.b #7,d0 * char is A,B,...
rts
*------------------------------------------------------------------------------*
scrline: * special printing for the screen
movem.l d4/a4,-(sp) * save d4, a4
move.b #13,d0 * go to start of line
bsr prt_chr
lea str,a4 * beggining of the ascii line
moveq #0,d4 * counter
scrloop move.b (a4)+,d0 * the char to print
cmpi.b #1,d4 * test start address area
bne scrl_1
bsr rev_on
scrl_1 cmpi.b #11,d4 * test end address area
bne scrl_2
bsr rev_off
scrl_2 cmpi.b #62,d4 * test start ascii area
bne scrl_3
bsr rev_on
scrl_3 cmpi.b #78,d4 * test end ascii area
beq scrl_ex
moveq #5,d1 * device is console without control
bsr conout * print
addq.b #1,d4
bra scrloop * loop until d4 > 77
scrl_ex bsr rev_off
move.b #13,d0 * go to start of line
bsr prt_chr
movem.l (sp)+,d4/a4 * restore saved register
rts
*------------------------------------------------------------------------------*
showln: * display the line to the screen
bsr adr_hx * address to hexadecimal ascii
bsr infbyte * byte to hexa value and char ascii
bra scrline * display
*------------------------------------------------------------------------------*
input: * main action routine
bsr ch_input * read user input
inptst: cmpi.l #ret_key,d0 * exit key ?
beq inp_ex * yes, return
cmpi.b #'Q',d0
beq inp_ex
cmpi.b #'q',d0
beq inp_ex
cmpi.l #$500000,d0 * down key ?
beq down * display one line down
cmpi.b #'V',d0
beq down
cmpi.b #'v',d0
beq down
cmpi.l #$480000,d0 * up key ?
beq up * display one line up
cmpi.b #'U',d0
beq up
cmpi.b #'u',d0
beq up
cmpi.l #$4d0000,d0 * right key
beq right * move right
cmpi.b #'R',d0
beq right
cmpi.b #'r',d0
beq right
cmpi.l #$4b0000,d0 * left key
beq left * move left
cmpi.b #'L',d0
beq left
cmpi.b #'l',d0
beq left
cmpi.l #$4d0036,d0 * shift right key
beq sh_right * move in ascii area
bra input * infinite loop
inp_ex rts
*------------------------------------------------------------------------------*
down: * response to down key
move.w #-1,cur_fg * no horizontal move flag
lea n_line,a0 * new line
bsr prt_str
adda.l #16,a5 * update address
bsr showln * display line
bra input * ready for next input
*------------------------------------------------------------------------------*
up: * response to up key
move.w #-1,cur_fg * no horizontal move flag
lea up_ln,a0 * move cursor up and to the beginning
bsr prt_str
suba.l #16,a5 * update address
bsr showln * display line
bra input * ready for next input
*------------------------------------------------------------------------------*
left: * response to left key
tst.w cur_fg * byte zero ?
beq l_beg * yes, go to beginning of line
cmpi.w #-1,cur_fg * beginning of line ?
beq end_prv * go to last byte of previous line
moveq #3,d1 * else move left 3 char
subq.w #1,cur_fg * and update flag
bsr l_move
bra mem_wr * ready to modify the byte
end_prv move.w #15,cur_fg * update flag
suba.l #16,a5 * update address
lea up_ln,a0 * one line up
bsr prt_str
moveq #58,d1 * move to the previous byte
bsr r_move
bra mem_wr
l_beg moveq #13,d0 * carriage return
bsr prt_chr
move.w #-1,cur_fg * update flag
bra input * ready for next input
*------------------------------------------------------------------------------*
right: * response to right key
cmpi.w #-1,cur_fg * flag = -1 ?
beq byte0 * yes, move to the first line byte
cmpi.w #15,cur_fg * flag >= 15 ? (16 bytes only)
bge down * yes, one line down
moveq #3,d1
r_cont bsr r_move * else move right 3 char
addq.w #1,cur_fg * and update flag
bra mem_wr * ready to modify the byte
byte0 moveq #13,d1 * move to the first line byte
bra r_cont
*------------------------------------------------------------------------------*
mem_wr: * write a byte in the line
bsr cur_s * save cursor pos
clr.b wr_fg * clear the flag
clr.w d2
bsr rd_hx * read 1st nibble
tst.b wr_fg * flag clear ?
beq other
move.b d1,d2 * store result
lsl.w #4,d2 * mult by 16
bsr rd_hx * take second nibble
add.b d1,d2 * add to previous value
move.w cur_fg,d0
move.b d2,0(a5,d0.w) * write the new value
bsr showln * redisplay line
bsr cur_r * restore cursor pos
bra mem_wr * re_write or next input
other bsr cur_r * restore cursor pos
bra inptst * test for other kind of input
*------------------------------------------------------------------------------*
rd_hx: * test hexa char value
* don't return until valid char is read
* value hold in d1, char in d0
st altd_fg * set altered flag
bsr ch_input * read one char
movem.l d0,-(sp) * save d0
cmpi.l #$400000,d0 * not ascii ?
bcc v_err * do other test
bsr asc_hx * convert to hexa value
bvs v_err * error ? go termination
move.b d0,d1 * the return value
movem.l (sp)+,d0 * restore d0
st wr_fg * set flag
cmpi.b #97,d0 * if lower case, do upper case
bcs do_prt
subi.b #32,d0
do_prt bra prt_chr * print it, and return
v_err movem.l (sp)+,d0 * restore d0
tst.b wr_fg * non valid
bne rd_hx * if second char, re-read
rts * else return
*------------------------------------------------------------------------------*
cur_s: * save cursor position
lea c_s,a0
bra prt_str
*------------------------------------------------------------------------------*
cur_r: * save cursor position
lea c_r,a0
bra prt_str
*------------------------------------------------------------------------------*
r_move: * move d1 step to right
lea mv_str,a0
subq.w #1,d1 * counter
r_fill move.b #27,(a0)+ * fill the move string
move.b #67,(a0)+
dbra d1,r_fill
clr.b (a0)
lea mv_str,a0
bra prt_str * move
*------------------------------------------------------------------------------*
l_move: * move d1 step to left
lea mv_str,a0
subq.w #1,d1 * counter
l_fill move.b #27,(a0)+ * fill the move string
move.b #68,(a0)+
dbra d1,l_fill
clr.b (a0)
lea mv_str,a0
bra prt_str * move
*------------------------------------------------------------------------------*
sh_right: * response to shift left key
moveq #13,d0 * carriage return
bsr prt_chr
a_area moveq #62,d1 * move to ascii area
bsr r_move
move.w #0,cur_fg * 1st char position
rd_asc bsr ch_input * read one char
cmpi.l #$4b0034,d0 * shift left arrow ?
beq sh_l_ex * yes, exit shift left routine
cmpi.l #$500000,d0 * down key ?
beq a_down * go one line down
cmpi.l #$480000,d0 * up key ?
beq a_up * go one line up
cmpi.l #$4b0000,d0 * left key
beq a_left * go left one char
cmpi.l #$4d0000,d0 * right key
beq a_right * go right one char
wr_asc st altd_fg * set altered flag
move.w cur_fg,d1
move.b d0,0(a5,d1.w) * write the new value
bsr cur_s * save cursor pos
bsr showln * redisplay line
bsr cur_r * restore cursor pos
a_right moveq #1,d1
bsr r_move * move one char right
addq.w #1,cur_fg * update cursor flag
cmpi.w #15,cur_fg * flag <= 15 ?
ble rd_asc * yes, next char
a_down move.w #0,cur_fg * set cursor flag
lea n_line,a0 * new line
bsr prt_str
adda.l #16,a5 * update address
bsr showln * display line
bra a_area * ready for next char
a_left moveq #1,d1
bsr l_move * move one char left
subq.w #1,cur_fg * update cursor flag
tst.w cur_fg * non negative ?
bpl rd_asc * yes, next char
a_up move.w #0,cur_fg * set cursor flag
lea up_ln,a0 * move cursor up and to the beginning
bsr prt_str
suba.l #16,a5 * update address
bsr showln * display line
bra a_area * ready for next char
sh_l_ex moveq #13,d0 * carriage return
bsr prt_chr
move.w #-1,cur_fg * reset cursor flag
bra input * ready for next input
*------------------------------------------------------------------------------*
*------------------------ Disassembler main routine ---------------------------*
*------------------------------------------------------------------------------*
sel_D: bsr outputf * get output
bsr inputf * get input
bclr #0,save1st+3 * odd address ?
move.l save1st,a5
cmpi.b #'S',outdev * Screen ?
beq S_dis
bra F_dis * file: printer or disk
*------------------------------------------------------------------------------*
S_dis bsr disasm
lea str,a0 * output
bsr prt_str
bsr ch_input
cmpi.l #ret_key,d0 * loop until exit key
beq exit
cmpi.b #'Q',d0
beq exit
cmpi.b #'q',d0
beq exit
bra S_dis
*------------------------------------------------------------------------------*
F_dis move.l saveend,d0 * while start address < end address
cmp.l a5,d0
bcs exit * (return)
bsr disasm
lea str,a0 * write buffer
move.l d3,d0 * number of char to output
move.w ohandle,d1 * output file handle
bsr write * write string
bra F_dis * ready for next line
*------------------------------------------------------------------------------*
disasm:
movea.l a5,a4 * a5 is the address of the opcode
addq.l #2,a4 * a4 the next (extention) word
lea str+mnemo,a3 * start of mnemotechnics code
bsr drv * disassemble
lea str,a0 * print address
move.b #13,(a0)+
move.b #10,(a0)+
move.b #' ',(a0)+
move.l a5,d2
bsr d2_hx_l
addi.l #8,a0
move.b #' ',(a0)+
move.b #' ',(a0)+
move.b #' ',(a0)+
opcode move.w (a5)+,d2 * print opcode
bsr d2_hx_w
addq.l #4,a0
move.b #' ',(a0)+
cmpa.l a5,a4
bhi opcode
lea str,a1 * space up to column before mnemo.
adda.l #mnemo-1,a1
col_mne move.b #' ',(a0)+
cmpa.l a0,a1
bcc col_mne
lea str,a0 * upon return d3 is the string length
move.l a3,d3
sub.l a0,d3
rts
*------------------------------------------------------------------------------*
term clr.b (a3) * terminate mnemo. string
rts
*------------------------------------------------------------------------------*
*------------------------- Trace main routine ---------------------------------*
*------------------------------------------------------------------------------*
sel_T: bsr outputf * get output
bsr inputf * get input
tst.b nil_val * if memory input and default value
bne sel_T_0 * take default parameter
bclr #0,save1st+3 * odd address ?
move.l save1st,cur_adr * become current address
sel_T_0 bra trace * initialise trace
*------------------------------------------------------------------------------*
trace: * initialise trace
clr.b sp_up * stack up flag
clr.b sp_dn * stack down flag
clr.b sp_eq * stack equal flag
move.l #trace_rout,$24 * trace vector
move.l prg_sp,sp * change monitor stack for prg stack
move.l cur_adr,-(sp) * start address to trace
move SR,d0
move.w saveCCR,d1 * restore previously saved CCR
andi.w #$ff,d1
or.w d1,d0
ori.w #$8000,d0 * set trace bit
move.w d0,-(sp)
movem.l regs,d0-d7/a0-a6 * restore previously saved register
rte * do trace
*------------------------------------------------------------------------------*
trace_rout: * trace routine
move SR,saveCCR * save CCR
movem.l d0-d7/a0-a7,regs * save register
addq.l #6,regs+60 * a7 before exeption
tst.b sp_up * if shift left key has been hitted
bne do_up * wait sp go up
tst.b sp_dn * if shift right key has been hitted
bne do_dn * wait sp go down
tst.b sp_eq * if shift equal key has been hitted
bne do_eq * wait sp go up or down
trcshow move.l cur_adr,a5 * PC value
lea str,a3
cmpi.b #'S',outdev * Screen ?
beq S_trace
bsr dis_trc * (here file=output) dissassemble
bsr reg_disp * register info
lea str,a0 * write buffer
move.l d3,d0 * number of char to output
move.w ohandle,d1 * output file handle
bsr write * write string
lea str,a0 * and also print to screen
bsr prt_str * but no reverse video mode...
trcloop btst #7,(sp) * test the Trace bit of SR
bne trc1 * if set, continue
lea excep_s,a0 * else it is an other exception
bsr prt_str * give info
move.l 8(sp),cur_adr * for the next instruction
bra trc2
trc1 move.l 2(sp),cur_adr * for the next instruction
trc2 movem.l regs,d0-d7/a0-a6 * restore register
rte * ready for next instruction
S_trace lea r_on_s,a0 * (here screen=output)
bsr copy_s * enter reverse video mode
bsr dis_trc * dissassemble
lea r_off_s,a0
bsr copy_s * exit reverse video mode
bsr reg_disp * register info
lea str,a0
bsr prt_str
bsr ch_input * pause
cmpi.l #$4d0036,d0 * shift right arrow ?
beq trc_rgt * wait sp go down (like in BSR)
cmpi.b #'R',d0
beq trc_rgt
cmpi.b #'r',d0
beq trc_rgt
cmpi.l #$4b0034,d0 * shift left arrow ?
beq trc_lft * wait sp go up (like in RTS)
cmpi.b #'L',d0
beq trc_lft
cmpi.b #'l',d0
beq trc_lft
cmpi.b #$2b,d0 * equal key ?
beq trc_equ * wait sp go up or down
cmpi.l #ret_key,d0 * exit key ?
beq trc_ex
cmpi.b #'Q',d0
beq trc_ex
cmpi.b #'q',d0
beq trc_ex
bra trcloop * no, loop
trc_ex btst #7,(sp) * test the Trace bit of SR
bne trc11 * if set, continue
move.l 8(sp),cur_adr * for the next instruction
bra trc22
trc11 move.l 2(sp),cur_adr * for the next instruction
trc22 move.l sp,prg_sp * save program stack pointer
addq.l #6,prg_sp
andi #$7fff,SR * clear trace bit
bra exit * return
*-----------------------------------------------------------------------------*
* routine answer to the shift up or down and equal key
trc_rgt st sp_dn * set down stack flag
bra trcnt
trc_lft st sp_up * set up stack flag
bra trcnt
trc_equ st sp_eq * set equal stack flag
trcnt clr.l trcount * initialise counter
move.l sp,sp_1st * stack pointer reference
lea work_s,a0 * working...
bsr prt_str
bra trcloop * trace next instruction
* note: add 6 for the current instruction sp. since the comparison (below)
* will be do after the trace exception, this relative value is correct
do_up cmpa.l sp_1st,sp * new sp is higher than old ?
bgt dotrcnt * display intruction count, continue
addq.l #1,trcount * update instruction counter
bra trcloop * do_up again (skip display)
do_dn cmpa.l sp_1st,sp * new sp is lower than old ?
blt dotrcnt * display intruction count, continue
addq.l #1,trcount * update instruction counter
bra trcloop * do_dn again (skip display)
do_eq cmpa.l sp_1st,sp * new sp is no equal to the old ?
bne dotrcnt * display intruction count, continue
addq.l #1,trcount * update instruction counter
bra trcloop * do_eq again (skip display)
dotrcnt move.l trcount,d2 * number of instruction traced
lea trcnt_s+10,a0 * message
bsr d2_hx_l * number to hex
lea trcnt_s,a0 * print hex value
bsr prt_str
clr.b sp_up * stack up flag
clr.b sp_dn * stack down flag
clr.b sp_eq * stack equal flag
bra trcshow * display last traced instruction
*------------------------------------------------------------------------------*
dis_trc: * show the disassembled trace instr.
movea.l a5,a4 * a5 is the address of the opcode
addq.l #2,a4 * a4 the next (extention) word
bsr disp_CCR * fill s_CCR with a5 adr. and codeCCR
lea s_CCR,a0
bsr copy_s * copy to str
bsr drv * disassemble
move.b #' ',(a3)+
clr.b (a3)
move.l a3,d3
sub.l #str,d3 * byte number
rts
*------------------------------------------------------------------------------*
disp_CCR: * fill s_CCR with a5 adr. and codeCCR
lea s_CCR+3,a0
move.l a5,d2
bsr d2_hx_l * show address
moveq #4,d2
lea s_CCR+22,a0 * status string address
lea codeCCR,a1 * status code
CCRtest btst d2,saveCCR+1 * test bit d2 of CCR
bne CCRnot0
move.b #'-',(a0)+ * bit = 0 -> "-"
addq.l #1,a1 * next code
bra CCRloop
CCRnot0 move.b (a1)+,(a0)+ * one of X,N,Z,V,C code
CCRloop dbra d2,CCRtest
rts
*------------------------------------------------------------------------------*
reg_disp: * display register info at a3
lea regs,a2 * register value
move.b #13,(a3)+ * carriage return
move.b #10,(a3)+ * line feed
move.b #'D',(a3)+
bsr reg_hx * display data register
move.b #13,(a3)+ * carriage return
move.b #10,(a3)+ * line feed
move.b #'A',(a3)+
bsr reg_hx * display address register
clr.b (a3)
move.l a3,d3
sub.l #str,d3 * byte number
rts
reg_hx moveq #7,d3 * loop counter
reg_lp move.b #' ',(a3)+
move.l (a2)+,d2 * register value
movea.l a3,a0
bsr d2_hx_l * to ascii
adda.l #8,a3 * update pointer
dbra d3,reg_lp * and loop until d3 = -1
rts
*------------------------------------------------------------------------------*
*----------------------- input source, output destination----------------------*
*------------------------------------------------------------------------------*
outputf: * get output device
clr.w ohandle
lea out_s,a0
bsr select * screen, exit, printer or file ?
tst.b d0 * default ?
bne outsave
moveq #'S',d0 * default is screen
outsave move.b d0,outdev
cmpi.b #'E',d0 * Exit
beq exit
cmpi.b #'S',d0 * Screen
beq outp_ex * just return
cmpi.b #'F',d0 * File
beq create * create file
cmpi.b #'P',d0
bne outputf
move.w #3,ohandle * handle for printer
outp_ex rts
*------------------------------------------------------------------------------*
inputf: * get input device
clr.w ihandle
lea in_s,a0
bsr select * exit, memory, program or data file ?
tst.b d0 * default ?
bne insave
moveq #'M',d0 * default is memory
insave move.b d0,indev
cmpi.b #'E',d0 * Exit
beq exit
cmpi.b #'D',indev
beq d_input * input is a data file
cmpi.b #'P',indev
beq p_input * input is a program file
cmpi.b #'M',indev
beq m_input * input is memory
bra inputf
*------------------------------------------------------------------------------*
m_input: * get memory address
lea adr_1st,a0 * start address
bsr prt_str
cmpi.b #'S',op_main * in Search, need both address
beq m_inp2
cmpi.b #'M',op_main * in Move (data), need both address
beq m_inp2
cmpi.b #'T',op_main * in Trace, need only one address
beq m_inp1
cmpi.b #'S',outdev * for other option
bne m_inp2
m_inp1 bsr get_a5 * if output is screen no need end adr.
tst.b nil_val * default ?
beq m_inp_
move.l cur_adr,a5 * default is current adr.
m_inp_ move.l a5,save1st * save start address
rts
m_inp2 lea c_s,a0 * save cursor position
bsr prt_str
bsr get_a5 * end address
tst.b nil_val * default ?
beq m_2_
move.l cur_adr,a5 * default is current adr.
m_2_ move.l a5,save1st * save start address
lea c_r,a0 * restore cursor position
bsr prt_str
lea adr_end,a0
bsr prt_str
bsr get_a5
tst.b nil_val * default ?
beq m_2__
move.l save1st,a5 * default is start adr. + $ffff
adda.l #$ffff,a5
m_2__ move.l a5,saveend * save end address
movea.l a5,a4 * end address
movea.l save1st,a5 * restore start address
rts
*------------------------------------------------------------------------------*
d_input: * get input data file
lea idname,a0 * input data filename
bsr getname * pathname or filename
bsr getsize * size of the file
move.l d4,d0
bsr Malloc * reserve memory space
move.l d0,a5 * start address
move.l a5,save1st
move.l d0,a4
adda.l d4,a4 * end address
move.l a4,saveend
lea idname,a0 * input data filename
bsr open * open file
bsr read * read file
bra Data_info * display start and end address
*------------------------------------------------------------------------------*
getsize: * d4 hold the size of the file 'idname'
move.w #$2f,-(sp) * function number: get dta
trap #gemdos * get disk transfert address
addq.l #2,sp * update stack
move.l d0,dta
move.w #-1,-(sp) * file affribute: any kind
move.l #idname,-(sp) * address of pathname or filename
move.w #$4e,-(sp) * function number: sfirst
trap #gemdos * file exist ?
addq.l #8,sp * update stack
tst.w d0
bne io_error * file not found
move.l dta,a0 * here file exist: found file size
move.l 26(a0),d4 * size
rts
*------------------------------------------------------------------------------*
Malloc: * byte space in d0, return adr in d0
move.l d0,-(sp) * reserve space
move.w #$48,-(sp) * function number: Malloc
trap #gemdos
addq.l #6,sp * update stack
tst.l d0 * <= 0 is error
ble no_mem
rts
no_mem moveq #-39,d0 * insufficient memory
bra io_error
*------------------------------------------------------------------------------*
Mshrink: * shrink block at a0 to d0 size
move.l d0,-(sp) * length of memory to free
move.l a0,-(sp) * start address of this memory
move d0,-(sp) * junk word
move #$4a,-(sp) * function number (Mshrink)
trap #gemdos
add.l #12,sp * update stack
rts
*------------------------------------------------------------------------------*
Data_info: * display start and end address
move.l a5,d2 * start address
lea from_s+11,a0
bsr d2_hx_l * value to ascii
move.l a4,d2 * end address
lea from_s+24,a0
bsr d2_hx_l * value to ascii
lea from_s,a0
bra prt_str * display
*------------------------------------------------------------------------------*
p_input: * get input program file
tst.l base_pg * first prg loaded ?
beq p_inp2 * if zero, it is first
movea.l base_pg,a0 * else release memory of previous prg
moveq #0,d0
bsr Mshrink
p_inp2 lea ipname,a0 * input prg filename
bsr getname * pathname or filename
bsr argline * split filename and command tail
bsr loadprg * load, but not execute
bra Prg_info * display base page info
*------------------------------------------------------------------------------*
Prg_info: * display base page info
move.l d0,base_pg * base page
move.l d0,a1
lea b_pg_s+11,a0 * show text start
move.l $8(a1),d2 * start address
movea.l d2,a5
move.l d2,cur_adr * become current adr.
move.l d2,save1st * save it
bsr d2_hx_l
lea b_pg_s+21,a0 * show text end
move.l $c(a1),d2 * text length
add.l $8(a1),d2
subq.l #1,d2 * end address
movea.l d2,a4
move.l d2,saveend * save it
bsr d2_hx_l
lea b_pg_s+38,a0 * show data start
move.l $10(a1),d2 * start address
bsr d2_hx_l
lea b_pg_s+48,a0 * show data end
move.l $14(a1),d2 * data length
add.l $10(a1),d2
subq.l #1,d2 * end address
bsr d2_hx_l
lea b_pg_s+64,a0 * show bbs start
move.l $18(a1),d2 * start address
bsr d2_hx_l
lea b_pg_s+74,a0 * show bbs end
move.l $1c(a1),d2 * text length
add.l $18(a1),d2
subq.l #1,d2 * end address
bsr d2_hx_l
lea b_pg_s,a0 * print it
bra prt_str
*------------------------------------------------------------------------------*
altered: * altered file need save ?
tst.b altd_fg * file altered ?
beq altd_ex * no, return
cmpi.b #'S',outdev * output is screen ?
bne altd_ex * no, return
cmpi.b #'D',indev * input is data file ?
bne altd_ex * no, return
lea altd_s,a0 * yes, display message
bsr select * answer
cmpi.b #'Y',d0
bne altd_ex * not Y, return
lea idname,a0 * input data filename
bsr open * pathname already in idname
move.w ihandle,d1 * file handle
move.l save1st,a0 * beggining of write buffer
move.l saveend,d0
sub.l a0,d0 * buffer length
bsr write * save it
bra ch_input
altd_ex rts
*------------------------------------------------------------------------------*
select: * user option
bsr prt_str * print option
moveq #2,d0 * read 2 char max.
lea str,a0
bsr read_str
tst.b d0 * default ?
beq sel_ex
move.b (a0),d0 * option
cmpi.b #'a',d0
bcs sel_ex
subi.b #32,d0 * to upper case
sel_ex rts
*------------------------------------------------------------------------------*
getname: * get pathname (and command tail)
move.l a0,-(sp) * save filename address
lea name_s,a0 * message
bsr prt_str
move.l (sp)+,a0 * restore filename address
moveq #70,d0 * 64 char max
bra read_str
*------------------------------------------------------------------------------*
argline: * split filename and command tail
lea ipname,a1
bsr get_arg * get filename
cmpa.l #0,a3 * other argument ?
bne arg1 * there is argument!
clr.b 1(a2) * end of ipname
clr.b tail * number of argument (zero)
rts
arg1 clr.b 1(a2) * end of ipname
movea.l a3,a1 * start of the next argument
lea tail+1,a3 * tail adr. + 1
movea.l a1,a0 * copy next arument to tail
bsr copy_s
clr.b (a3) * null terminate
moveq #1,d1 * number of argument counter
argplus bsr get_arg * find argument
cmpa.l #0,a3 * other argument ?
beq arg_ret * while not end of string
movea.l a3,a1 * start of the next argument
addq.b #1,d1 * number of argument
bra argplus
arg_ret move.b d1,tail * number of argument in 1st byte
rts
*------------------------------------------------------------------------------*
get_arg:
* a1 is the beginning of the argument, a2 will be the end of argument
* a3 will be the beginning of the next argument, or 0 if there are not
* other argument. skip white space and tab
movea.l a1,a0
non_w move.b (a0)+,d0 * current char
beq no_arg * end of string, no more argument
cmpi.b #' ',d0 * white space ?
beq skip_w
cmpi.b #tab,d0 * tab ?
bne non_w * ckeck another char
skip_w lea -2(a0),a2 * end of argument
skip_l move.b (a0)+,d0 * current char
cmpi.b #' ',d0 * white space ?
beq skip_l
cmpi.b #tab,d0 * tab ?
beq skip_l
lea -1(a0),a3 * beginning of the next argument
rts
no_arg lea -1(a0),a2 * end of argument
movea.l #0,a3 * no other argument
rts
*------------------------------------------------------------------------------*
get_a5: * get deci or hexa value to a5
clr.b nil_val * no value flag
moveq #15,d0 * 12 char max
lea str,a0 * read address
bsr read_str
tst.b d0 * number of char read
beq no_val * if 0, give info
cmpi.b #'#',(a0) * 1st char is # ?
beq get_dec * yes, decimal value
bsr a_to_hx * else hexa value
bra mv_adr
get_dec addq.l #1,a0 * skip char #
bsr a_to_dec
mv_adr movea.l d1,a5 * address
rts
no_val st nil_val * set flag
clr.l a5 * why not ?
rts
*------------------------------------------------------------------------------*
*--------------------------- I/O routine --------------------------------------*
*------------------------------------------------------------------------------*
close: * close file
move.w d0,-(sp) * file handle
move.w #$3e,-(sp) * function number: Fclose
trap #gemdos
addq.l #4,sp * update stack
tst.w d0
bmi io_error * d0 < 0 is error
rts
*------------------------------------------------------------------------------*
open: * open a file on disk
move.w #2,-(sp) * can be read or write
move.l a0,-(sp) * address of pathname or filename
move.w #$3d,-(sp) * function number
trap #gemdos
addq.l #8,sp * update stack
move.w d0,ihandle * input file handle
tst.w d0
bmi io_error * d0 < 0 is error
rts
*------------------------------------------------------------------------------*
write: * write on file (disk or printer)
move.l a0,-(sp) * text buffer
move.l d0,-(sp) * length of text
move.w d1,-(sp) * file handle
move.w #$40,-(sp) * function number: Fwrite
trap #gemdos
adda.l #12,sp * update stack
tst.l d0
bmi io_error * d0 < 0 is error
move.w #$b,-(sp) * function number: Cconis
trap #gemdos * (check keyboard status)
adda.l #2,sp * update stack
tst.w d0 * press one key ?
beq write_x * 0 -> no
wr_ch bsr ch_input * -1 -> yes, then read it
cmpi.l #ret_key,d0 * exit key ?
beq exit * yes, close file and exit
cmpi.b #'Q',d0
beq exit
cmpi.b #'q',d0
beq exit
cmpi.b #spc,d0 * space bar ?
beq wr_wait * yes, pause
write_x rts * if not: ignore the key, continue
wr_wait not.b wait_fg * 1 -> first time: wait
bne wr_p * 0 -> second time: continue
lea cont_s,a0
bsr prt_str
rts
wr_p lea pause_s,a0
bsr prt_str
bra wr_ch * wair for an other hit (space bar)
*------------------------------------------------------------------------------*
read: * read file
move.l a5,-(sp) * text buffer
move.l d4,-(sp) * length of text
move.w ihandle,-(sp) * file handle
move.w #$3f,-(sp) * function number: Fread
trap #gemdos
adda.l #12,sp * update stack
tst.l d0
bmi io_error * d0 < 0 is error
rts
*------------------------------------------------------------------------------*
create: * create (and open) a file on disk
lea odname,a0 * output data filename
bsr getname
move.w #0,-(sp) * R/W status
pea odname * address of pathname or filename
move.w #$3c,-(sp) * function number: Fcreate
trap #gemdos
addq.l #8,sp * update stack
move.w d0,ohandle * output file handle
tst.w d0
bmi io_error * d0 < 0 is error
rts
*------------------------------------------------------------------------------*
loadprg: * load program and show base page info
clr.l -(sp) * no environment string
pea tail * command tail address
pea ipname * pathname
move.w #3,-(sp) * load, but not execute
move.w #$4b,-(sp) * function number: Pexec
trap #gemdos
add.l #16,sp * update stack
tst.l d0
bmi io_error
move.l #prg_stk-8,prg_sp * set program stack pointer
move.l #over,prg_stk-8 * prg stack gate
move.l d0,prg_stk-4 * basepage address
rts
*------------------------------------------------------------------------------*
io_error: * message: I/O error
lea io_er_s+17,a0
clr.l d2
move.b d0,d2 * error no
neg.b d2
bsr d2_hx_w * conversion
lea io_er_s,a0
bsr prt_str
bsr ch_input
bra exit
*------------------------------------------------------------------------------*
rev_on: * enter in reverse video mode
lea r_on_s,a0
bra prt_str
*------------------------------------------------------------------------------*
rev_off: * exit reverse video mode
lea r_off_s,a0
bra prt_str
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
read_chr * read a char from keyboard
* scan code (hi) + char (lo) read is in d0
movem.l a0,-(sp) * other register not affected
move.w #1,-(sp)
trap #gemdos * Cconin
addq.l #2,sp
movem.l (sp)+,a0
rts
*------------------------------------------------------------------------------*
prt_chr * print char in d0
movem.l d0/a0,-(sp) * register not affected
move.w d0,-(sp)
move.w #2,-(sp)
trap #gemdos * Cconout
addq.l #4,sp
movem.l (sp)+,d0/a0
rts
*------------------------------------------------------------------------------*
prt_str * print string located at address a0
* string must be null terminated
movem.l d0/a0,-(sp) * register not affected
move.l a0,-(sp)
move.w #9,-(sp)
trap #gemdos
addq.l #6,sp
movem.l (sp)+,a0/d0
rts
*------------------------------------------------------------------------------*
read_str * read a string of max length d0 (d0<256)
* a0 is the address of return string
* (null terminated) and must point to a room
* of d0 + 3 bytes
* upon return d0 is the number of char read
* other register not affected
move.l a0,-(sp) * save buffer address
move.b d0,(a0) * put the max in the first byte
move.l a0,-(sp)
move.w #$A,-(sp)
trap #gemdos * Cconrs
addq.l #6,sp
clr.l d0
movea.l (sp),a0 * restore buffer address
move.b 1(a0),d0 * number of char actually read
beq read_0 * if no char are read
movem.l d0/a1,-(sp) * save register
lea 2(a0),a1
subq.b #1,d0
copy_rd move.b (a1)+,(a0)+
dbra d0,copy_rd
move.b #0,(a0) * the null
movem.l (sp)+,d0/a1 * restore register
read_0 movea.l (sp)+,a0 * restore buffer address
rts
*------------------------------------------------------------------------------*
ch_input: * read a char from keyboard, whitout echo
* scan code (hi) + char (lo) read is in d0
movem.l a0,-(sp) * other register not affected
move.w #8,-(sp)
trap #gemdos * Cnecin
addq.l #2,sp
movem.l (sp)+,a0
rts
*------------------------------------------------------------------------------*
conout move.w d0,-(sp) * char
move.w d1,-(sp) * device
move.w #3,-(sp) * function number
trap #bios
addq.l #6,sp * update stack
rts
*------------------------------------------------------------------------------*
*----------------------- Exeption handling routine ----------------------------*
*------------------------------------------------------------------------------*
excep_new: * initialise new exception vector
lea exepold,a0 * save area for old exception vector
lea exepnew,a1 * new exception vector
movea.l #8,a2 * begin change at vector 2
moveq #2,d0 * change 3 vector
exepnlp move.l (a2),(a0)+ * store old value
move.l (a1)+,(a2)+ * set new value
dbra d0,exepnlp
rts
excep_old: * restore exception vector
lea exepold,a0 * save area for old exception vector
movea.l #8,a2 * begin change at vector 2
moveq #2,d0 * change 3 vector
exepolp move.l (a0)+,(a2)+ * restore old value
dbra d0,exepolp
rts
v_bus lea s_bus,a0 * bus error
moveq #8,d0
bra do_exep
v_adr lea s_adr,a0 * address error
moveq #8,d0
bra do_exep
v_illeg lea s_illeg,a0 * illegal instruction
moveq #0,d0
bra do_exep
do_exep lea str,a3
move.b #13,(a3)+
move.b #10,(a3)+
bsr copy_s * error type
lea s_at,a0
bsr copy_s
move.l 2(a7,d0.w),d6 * PC at error
bsr hx_$
move.b #' ',(a3)+
move.b #'[',(a3)+
movea.l prg_sp,a0 * prg SP at error
move.l (a0),d6 * pointed value
bsr hx_$
move.b #' ',(a3)+
movea.l prg_sp,a0 * prg SP at error
move.l -4(a0),d6 * previous pointed value
bsr hx_$
move.b #']',(a3)+
move.b #10,(a3)+
clr.b (a3)
lea str,a0 * print
bsr prt_str
bra exit
*------------------------------------------------------------------------------*
asc_hx: * a char in d0 is converted to his
* hexa value. value is returned in d0
* overflow is set for a non hexa char
* and d0 (.b) is fill with 0.
* other register not affected
subi.b #48,d0
bcs no_v * '0' or greater
cmpi.b #9,d0
bls hx_ok * '9' or lower
subq.b #7,d0
cmpi.b #10,d0
bcs no_v * 'A' or greater
cmpi.b #15,d0
bls hx_ok * 'F' or lower
subi.b #32,d0
cmpi.b #10,d0
bcs no_v * 'a' or greater
cmpi.b #15,d0
bls hx_ok * 'f' or lower
no_v clr.b d0 * zero in d0
move #2,CCR * set overflow bit
hx_ok rts
*------------------------------------------------------------------------------*
a_to_hx: * a null terminated string located
* at a0 is converted to his hexa value
* return at the first non hexa value
* hexa value hold in d1
* other register not affected
movem.l d0/a0,-(sp) * save register
moveq #0,d0
moveq #0,d1
hx_nxt move.b (a0)+,d0 * char in d0
beq a_h_ex * char is zero ? then return
bsr asc_hx * convert in hexa value
bvs a_h_ex * no hexa value ? then exit
lsl.l #4,d1 * d1=16*d1
add.l d0,d1 * d1=d1+d0
bra hx_nxt * ready for next char
a_h_ex movem.l (sp)+,d0/a0 * restore register
rts
*------------------------------------------------------------------------------*
a_to_dec: * a null terminated string located
* at a0 is converted to his decimal
* value. return at the first non digit
* decimal value hold in d1
* other register not affected
movem.l d0/d2/a0,-(sp) * save register
moveq #0,d0
moveq #0,d1
dec_nxt move.b (a0)+,d0 * char in d0
subi.b #48,d0
bmi a_d_ex * '0' or greater
cmpi.b #9,d0
bgt a_d_ex * '9' or lower
move.l d1,d2 * let d1=val, d2=val
lsl.l #1,d2 * d2=2*d2=2*val
move.l d2,d1 * d1=d2=2*val
lsl.l #2,d2 * d2=4*d2=8*val
add.l d2,d1 * d1=d2+d1=10*val
add.l d0,d1 * d1=10*val+d1
bra dec_nxt * ready for next char
a_d_ex movem.l (sp)+,d0/d2/a0 * restore register
rts
*------------------------------------------------------------------------------*
hx_$: * value d6 to ascii in a3 (updated)
move.b #'$',(a3)+ * $ leader sign for hexa value
hx_no_$ tst.l d6 * here, no leader $ sign
beq hx_0
lea temp_s,a0 * temporary storage for the ascii str.
move.l d6,d2
bsr d2_hx_l * conversion to 8 char
moveq #7,d0 * char counter
lea temp_s,a0
not_0 cmpi.b #'0',(a0)+ * find the 1st non '0' char
dbne d0,not_0
subq.l #1,a0 * 1st non '0'
mv_hx move.b (a0)+,(a3)+ * copy the remainning
dbra d0,mv_hx
rts
hx_0 move.b #'0',(a3)+
rts
*------------------------------------------------------------------------------*
d2_hx_b: * d2 byte to hexadecimal ascii in a0
moveq #1,d1 * 2 bytes counter
bra nib_val * (in d2_hx_l)
*------------------------------------------------------------------------------*
d2_hx_w: * d2 word to hexadecimal ascii in a0
moveq #3,d1 * 4 bytes counter
bra nib_val * (in d2_hx_l)
*------------------------------------------------------------------------------*
d2_hx_l: * d2 long to hexadecimal ascii in a0
moveq #7,d1 * 8 bytes counter
nib_val move.b d2,d0 * byte value
andi.b #$F,d0 * low nibble
bsr do_nib
lsr.l #4,d2 * ready for the next
dbra d1,nib_val * loop until d1 > -1
rts
do_nib addi.b #48,d0 * ascii digit
cmpi.b #57,d0 * > 9 ?
bgt letter * no, it is a letter
bra store_c * store the digit
letter addq.b #7,d0
store_c move.b d0,0(a0,d1.w)
rts
*------------------------------------------------------------------------------*
adr_hx: * a5 address to hexadecimal ascii
lea str+2,a0 * hexa address area
move.l a5,d2
bra d2_hx_l
*------------------------------------------------------------------------------*
copy_s: * copy null terminated string a0 to a3
* null not copied, a3 updated
tst.b (a0)
beq copy_ex
move.b (a0)+,(a3)+
bra copy_s
copy_ex rts
*------------------------------------------------------------------------------*
*------------------------ disassembler main routine ---------------------------*
*------------------------------------------------------------------------------*
* a5 disassembled address (opcode)
* a4 extension word (or long) address
* a3 disassembled ascii string address
* d7 register no.
* d6 hexa. value to display
* d5 bit 12-15 of opcode
* d4 size
* d3 mode
*------------------------------------------------------------------------------*
*-------------------------- main driver subroutine ----------------------------*
*------------------------------------------------------------------------------*
drv: bsr code_m * first 4 bits of opcode in d5
beq v0000 * addi, xxxi, and test bit family
cmpi.b #%0011,d5
ble _move * move and movea
cmpi.b #%0100,d5
beq v0100 * chk and one operand instruction
cmpi.b #%0101,d5
beq v0101 * addq, dbcc, scc, subq
cmpi.b #%0110,d5
beq v0110 * bcc, bsr
cmpi.b #%0111,d5
beq v0111 * moveq
cmpi.b #%1000,d5
beq v1000 * divs, divu, or, sbcd
cmpi.b #%1001,d5
beq v1001 * sub, suba, subx
cmpi.b #%1011,d5
beq v1011 * cmp, cmpa, cmpm, eor
cmpi.b #%1100,d5
beq v1100 * abcd, and, exc, muls, mulu
cmpi.b #%1101,d5
beq v1101 * add, adda, addx
cmpi.b #%1110,d5
beq v1110 * rotation and shift familly
bra unknown
*------------------------------------------------------------------------------*
*-------------------------- second driver subroutine --------------------------*
*------------------------------------------------------------------------------*
v0000 btst #0,(a5) * if set -> test bit familly
bne tstbit
move.b (a5),d0
lsr.b #1,d0 * test only bit 9-11
cmpi.b #%100,d0
beq tstbit * %100 -> test bit familly
bra xxxi * other -> xxxi familly
*------------------------------------------------------------------------------*
v0100 btst #0,(a5) * bit 8 of opcode
bne _chk_lea * 1: -> chk or lea
move.b 1(a5),d4
lsr.b #6,d4 * size on some instruction
move.b (a5),d0
lsr.b #1,d0
andi.b #%111,d0 * bit 9-11 of opcode
bne v0100_1
cmpi.b #3,d4
beq mv_f_SR * move from SR
bra _negx * negx
v0100_1 cmpi.b #1,d0
bne v0100_2
bra _clr * clr
v0100_2 cmpi.b #2,d0
bne v0100_3
cmpi.b #3,d4
beq mv_CCR * move to CCR
bra _neg * neg
v0100_3 cmpi.b #3,d0
bne v0100_4
cmpi.b #3,d4
beq mv_t_SR * move to SR
bra _not * not
v0100_4 cmpi.b #4,d0
bne v0100_5
move.w (a5),d1
move.b d1,d0
lsr.w #6,d1
andi.b #%111,d1 * bit 6-8 of opcode
beq _nbcd * nbcd
cmpi.b #1,d1
bhi _ext_movem * ext or movem
andi.b #%00111111,d0 * bit 0-5 of opcode
cmpi.b #%00001000,d0
bcs _swap * mode 0: -> swap
bra _pea * mode >1 -> pea
v0100_5 cmpi.b #5,d0
bne v0100_6
cmpi.b #3,d4
bcs _tst * tst
cmpi.b #%11111100,1(a5)
beq _illegal * illegal
bra _tas * tas
v0100_6 cmpi.b #6,d0
bne v0100_7
bra _movem * (in _ext_movem)
v0100_7 move.w (a5),d1
lsr.w #6,d1
andi.b #%111,d1 * bit 6-8 of opcode
cmpi.b #%010,d1
beq _jsr * _jsr
bhi _jmp * _jmp
bcs misc
misc move.b 1(a5),d0
lsr.b #3,d0
andi.b #%111,d0 * bit 3-5 of opcode
cmpi.b #%010,d0
beq _link * link
bcs _trap * trap
cmpi.b #%011,d0
beq _unlk * unlk
cmpi.b #%110,d0
bcs mv_USP * move USP
move.b 1(a5),d0 * no operand instruction
cmpi.b #$70,d0
bne misc1
lea k_reset,a0 * reset
bra do_misc
misc1 cmpi.b #$71,d0
bne misc2
lea k_nop,a0 * nop
bra do_misc
misc2 cmpi.b #$72,d0
bne misc3
lea k_stop,a0 * stop
bra do_misc
misc3 cmpi.b #$73,d0
bne misc5
lea k_rte,a0 * rte
bra do_misc
misc5 cmpi.b #$75,d0
bne misc6
lea k_rts,a0 * rts
bra do_misc
misc6 cmpi.b #$76,d0
bne misc7
lea k_trapv,a0 * trapv
bra do_misc
misc7 lea k_rtr,a0
do_misc bsr copy_s
bra term
*------------------------------------------------------------------------------*
v0101 move.b 1(a5),d4
lsr.b #6,d4 * size
cmpi.b #%11,d4 * size < 3 mean addq or subq
bne _addq_subq
move.b 1(a5),d3 * else dbcc or scc
andi.b #%00111000,d3 * ea
cmpi.b #%00001000,d3
bne _scc * mode not %001 is for Scc
move.b #'D',(a3)+ * mode %001 is DBcc
bsr v0110 * (go to v0110 for the mnemo)
move.b 1(a5),d7 * do register no in DBcc
bsr data_reg
move.b #comma,(a3)+
move.w (a4)+,d6 * get displacement
ext.l d6
bra condis2 * do displacement
*------------------------------------------------------------------------------*
v0110 move.b #'B',(a3)+
clr.w d0
move.b (a5),d0
andi.b #%1111,d0 * condition code
cmpi.b #1,d0 * bf ?
beq cond_bf
bcs cond_bt * bt
cond2 lea cc_code,a0 * other in cc_code table
lsl.b #1,d0 * multiply by 2
adda.w d0,a0
move.b (a0)+,(a3)+ * two char
move.b (a0)+,(a3)+
condval move.b #tab,(a3)+
cmpi.b #%0110,d5 * Bcc or DBcc ?
beq condisp * if Bcc, continue
rts * else return
condisp bsr val8_16 * get displacement
condis2 add.l a5,d6 * next instruction add. + displacment
addq.l #2,d6 * plus 2
bsr hx_$ * to ascii
bra term
cond_bf cmpi.b #%0110,d5 * Bcc or DBcc ?
bne cond_bt * if DBcc, then dbra
move.b #'S',(a3)+ * else bsr
move.b #'R',(a3)+
bra condval
cond_bt move.b #'R',(a3)+ * bra or dbra
move.b #'A',(a3)+
bra condval
*------------------------------------------------------------------------------*
v0111 clr.l d6
lea k_move,a0
bsr copy_s * copy keyword
move.b #'Q',(a3)+
move.b #tab,(a3)+
move.b 1(a5),d6 * value for moveq
move.b #'#',(a3)+
bsr hx_$
move.b #comma,(a3)+
bsr reg_9_11 * register no
bsr data_reg * to ascii
bra term
*------------------------------------------------------------------------------*
v1000 move.w (a5),d3
lsr.w #6,d3
andi.w #%111,d3
cmpi.b #%011,d3 * divu
beq div_mul
cmpi.b #%111,d3 * divs
beq div_mul
move.w (a5),d3
andi.w #%111110000,d3
cmpi.w #%100000000,d3
bne op_md0
move.b #'S',(a3)+ * sbcd
bra _bcd
op_md0 lea k_or,a0 * or
op_md1 bsr copy_s * copy keyword
op_md2 bsr op_mode
bra term
*------------------------------------------------------------------------------*
v1001 lea k_sub,a0
bsr copy_s * copy keyword
bra _sub_add
*------------------------------------------------------------------------------*
v1011 move.w (a5),d3
lsr.w #6,d3
andi.w #%111,d3
cmpi.b #%011,d3 * cmpa word
beq _cmp
cmpi.b #%111,d3 * cmpa long
beq _cmp
btst #2,d3
beq _cmp * cmp
move.b 1(a5),d1
and.b #%00111111,d1
cmpi.b #%00001111,d1
bhi _eor * eor
lea k_cmp,a0 * now: cmpm
bsr copy_s * copy keyword
move.b #'M',(a3)+
moveq #%111,d2 * (Ay)+,(Ax)+ and need size id
bra RxRy
*------------------------------------------------------------------------------*
v1100 move.w (a5),d3
lsr.w #6,d3
andi.w #%111,d3
cmpi.b #%011,d3 * mulu
beq div_mul
cmpi.b #%111,d3 * muls
beq div_mul
btst #0,(a5)
beq _and * and
move.b 1(a5),d3
andi.b #%111111,d3
cmpi.b #%010000,d3 * mode >= 2
bcc _and * yes, it is and
move.b 1(a5),d3
cmpi.b #%1000000,d3
bcc _exg * exg
move.b #'A',(a3)+ * abcd
bra _bcd
lea k_and,a0
bsr copy_s * copy keyword
bsr op_mode
bra term
*------------------------------------------------------------------------------*
v1101 lea k_add,a0
bsr copy_s * copy keyword
bra _sub_add
v1110 move.b 1(a5),d4
lsr.b #6,d4 * size
cmpi.b #%11,d4 * mean rotation or shift in memory
beq rot_mem
move.b 1(a5),d2 * here, register destination
lsr.b #3,d2 * name id
bra rot_id
rot_mem move.b (a5),d2 * and here memory destination
lsr.b #1,d2
rot_id andi.b #%11,d2
tst.b d2
bne rot_1
move.b #'A',(a3)+ * asl, asr
move.b #'S',(a3)+
bra rotname
rot_1 cmpi.b #1,d2
bne rot_2
move.b #'L',(a3)+ * lsl, lsr
move.b #'S',(a3)+
bra rotname
rot_2 cmpi.b #2,d2
bne rot_3
move.b #'R',(a3)+ * rol, ror
move.b #'O',(a3)+
move.b #'X',(a3)+
bra rotname
rot_3 move.b #'R',(a3)+ * roxl, roxr
move.b #'O',(a3)+
rotname btst #0,(a5) * direction
bne rotleft
move.b #'R',(a3)+ * right direction
bra rot_sz
rotleft move.b #'L',(a3)+
rot_sz cmpi.b #%11,d4
bne rot_reg * register destination: need size
bra tab_ea * memory destination, no size
rot_reg bsr do_size
bsr reg_9_11 * bit 9-11 in d7
btst #5,1(a5) * source flag
beq rot_imm * 0: -> immediat
bsr data_reg * 1: -> Dx
bra rot_Dy
rot_imm move.b d7,d6 * source is immediat value in bit 9-11
bne r_imm_2
moveq #8,d6 * 0 mean 8 for this form
r_imm_2 move.b #'#',(a3)+
addi.b #'0',d6
move.b d6,(a3)+ * immediate value
rot_Dy move.b #comma,(a3)+
move.b 1(a5),d7 * destination register
bsr data_reg
bra term
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*---------------------------- addressing mode ---------------------------------*
*------------------------------------------------------------------------------*
reg_out: * register no (d7) to ascii no in a3
* a3 updated
andi.b #7,d7 * only last 4 bits
addi.b #'0',d7 * now ascii digit
move.b d7,(a3)+ * store char
rts
*------------------------------------------------------------------------------*
data_reg: * data register to ascii in a3
* [Dn], d7=n, a3 updated
move.b #'D',(a3)+
bra reg_out
*------------------------------------------------------------------------------*
adr_reg: * address register to ascii in a3
* [An], d7=n, a3 updated
move.b #'A',(a3)+
bra reg_out
*------------------------------------------------------------------------------*
indirect: * address register indirect
* to ascii in a3 (updated)
* [(An)], n=d7
move.b #'(',(a3)+
bsr adr_reg
move.b #')',(a3)+
rts
*------------------------------------------------------------------------------*
post_inc: * address register indirect post-
* increment to ascii in a3 (updated)
* [(An)+], n=d7
bsr indirect
move.b #'+',(a3)+
rts
*------------------------------------------------------------------------------*
pre_dec: * address register indirect pre-
* decrement to ascii in a3 (updated)
* [-(An)], n=d7
move.b #'-',(a3)+
bra indirect
*------------------------------------------------------------------------------*
indir_disp: * address register indirect with
* displacement to ascii in a3 (updated)
* [d(An)], n=d7, d=d6
* extension word -> a6 (a4 updated)
clr.l d6
move.w (a4)+,d6 * displacement value
bsr hx_$ * displacement in hexa
bra indirect * register no
*------------------------------------------------------------------------------*
index_disp: * address register indirect with
* displacement and index to ascii in a3
* (updated). d(An,Rm.sz). n=d7, d=d6
* extension word -> a4 (updated)
clr.l d6
move.b 1(a4),d6 * displacement value
bsr hx_$ * displacement to ascii
move.b #'(',(a3)+
cmpi.b #8,d7 * register no 8 mean PC
beq indx_PC
bsr adr_reg * An to ascii
indx_nx move.b #comma,(A3)+
move.b (a4),d7
lsr.b #4,d7 * m value (bit 0-2)
btst #7,(a4) * R: 0 -> D, 1 -> A
beq is_data
bsr adr_reg * Rm to ascii
bra mk_size
is_data bsr data_reg * Rm to ascii
mk_size move.b #'.',(a3)+
btst.b #3,(a4) * .L or .W to ascii
beq is_word * size: 0 -> word, 1 -> long
move.b #'L',(a3)+
bra do_sz
is_word move.b #'W',(a3)+
do_sz move.b #')',(a3)+ * end char ')'
addq.l #2,a4 * update a4
rts
indx_PC move.b #'P',(a3)+ * pc relative with index and disp.
move.b #'C',(a3)+
bra indx_nx
*------------------------------------------------------------------------------*
pc_disp: * program counter relative with
* displacement to ascii in a3 (updated)
* [d(PC)] displacement d=d1
* extension word -> a4 (updated)
clr.l d6
move.w (a4)+,d6 * displacement value
bsr hx_$ * displacement in hexa
move.b #'(',(a3)+
move.b #'P',(a3)+
move.b #'C',(a3)+
move.b #')',(a3)+
rts
*------------------------------------------------------------------------------*
pc_index: * program counter relative with
* displacement and index to ascii in a3
* (updated). d(PC,Rm.sz). d=d6
* extension word -> a4 (updated)
moveq #8,d7 * special value in index_disp
bra index_disp
*------------------------------------------------------------------------------*
abs_w: * absolute short addressing (in a4)
* [$1234] a3, a4 updated
clr.l d6
move.w (a4)+,d6
bra hx_$
*------------------------------------------------------------------------------*
abs_l: * absolute long addressing (in a4)
* [$123456] a3, a4 updated
move.l (a4)+,d6
bra hx_$
*------------------------------------------------------------------------------*
immediat: * immediat value to ascii in a3
* [#$1234] a3,a4 updated
clr.l d6
move.b #'#',(a3)+
cmpi.b #1,d4 * hold size
beq imm1
bhi imm2
move.w (a4)+,d6
andi.w #$ff,d6 * byte value, low byte of word
bra hx_$
imm1 move.w (a4)+,d6 * word value (update a4)
bra hx_$
imm2 move.l (a4)+,d6 * long value (update a4)
bra hx_$
*------------------------------------------------------------------------------*
unknown: * invalid opcode
lea str+mnemo,a3
move.b #'?',(a3)+
move.b #0,(a3)+
rts
*------------------------------------------------------------------------------*
*--------------------- addressiong mode combination ---------------------------*
*------------------------------------------------------------------------------*
reg_9_11: * register in bit 9-11 of opcode in d7
move.b (a5),d7
lsr.b #1,d7
andi.b #%111,d7
rts
*------------------------------------------------------------------------------*
ea_0_5: * address effective in bit 0-5 of (a5)
* extension in (a4)
clr.w d7
clr.w d3
move.b 1(a5),d7
move.b d7,d3
andi.b #%111000,d3 * mode*8 (in bit 3-5)
lsr.b #3,d3 * mode
andi.b #%111,d7 * register (go to do_md_rg)
*------------------------------------------------------------------------------*
do_md_rg: * do addressing mode in d3, reg in d7
lea mode_tb,a0
andi.w #7,d3
lsl.w #2,d3 * mode mult 4, table offset
adda.w d3,a0
movea.l (a0),a1
jmp (a1) * vector table for each mode and reg
tab_ea move.b #tab,(a3)+ * tab separator
bsr ea_0_5 * do effective address
bra term
com_ea move.b #comma,(a3)+ * comma separator
bsr ea_0_5 * do effective address
bra term
*------------------------------------------------------------------------------*
mode7: * mode 7 routine driver
lea md7_tb,a0
andi.w #7,d7
lsl.w #2,d7 * mult by 4, offset table
adda.w d7,a0
movea.l (a0),a1
jmp (a1)
*------------------------------------------------------------------------------*
code_m: * bits 12-16 in d5 for mnemotechnics
* codes
move.b (a5),d5
lsr.b #4,d5
rts
*------------------------------------------------------------------------------*
do_size: * .B, .W, .L according to value d4
* (0,1,2), a3 updated
move.b #'.',(a3)+
andi.b #%11,d4
bne do1
move.b #'B',(a3)+ * d4=0
move.b #tab,(a3)+
rts
do1 cmpi.b #1,d4
bne do2
move.b #'W',(a3)+ * d4=1
move.b #tab,(a3)+
rts
do2 move.b #'L',(a3)+ * d4=2
move.b #tab,(a3)+
rts
*------------------------------------------------------------------------------*
_sub_add: * do sub, suba, subx, add, adda, addx
btst #0,(a5) * bit 8 clear ?
beq op_md2 * go op_mode (in v1000)
move.b 1(a5),d3
cmpi.b #%11000000,d3
bcc op_md2 * suba or adda (long)
andi.b #%111111,d3
cmpi.b #%010000,d3 * mode is > 1 ?
bcc op_md2 * then it is op_mode (in v1000)
move.b #'X',(a3)+ * else it is subx or addx
move.b d3,d2
lsr.b #3,d2 * 0: -> dy,dx 1: -> -(Ay),-(Ax)
ori.b #%10,d2 * need size id
bra RxRy
*------------------------------------------------------------------------------*
RxRy: * used in abcd, cmpm, exc, sbcd
btst #1,d2 * need size id ?
bne RxRy_sz
move.b #tab,(a3)+
do_RxRy move.b (a5),d7
lsr.b #1,d7 * Rx
move.w d7,-(sp)
move.b 1(a5),d7 * Ry
btst #0,d2 * R=A ?
bne AxAy
bsr data_reg * Dy,Dx
move.w (sp)+,d7
move.b #comma,(a3)+
bsr data_reg
bra term
AxAy btst #2,d2 * -(A?) or (A?)+
bne Aplus
bsr pre_dec * -(Ay),-(Ax)
move.w (sp)+,d7
move.b #comma,(a3)+
bsr pre_dec
bra term
Aplus bsr post_inc * (Ay)+,(Ax)+
move.w (sp)+,d7
move.b #comma,(a3)+
bsr post_inc
bra term
RxRy_sz move.b 1(a5),d4
lsr.b #6,d4 * size
bsr do_size
bra do_RxRy
*------------------------------------------------------------------------------*
op_mode: * op_mode in bit 6-8
* used in add, and, cmp, eor, or, sub
move.w (a5),d3
lsr.w #6,d3
andi.w #%111,d3 * op-mode
cmpi.b #%011,d3
bne op_m1
moveq #1,d4 * word size
bra op_m3
op_m1 cmpi.b #%111,d3
bne op_m2
moveq #2,d4 * long size
bra op_m3
op_m2 move.b d3,d4
andi.b #%11,d4 * size for mode with Dn
lsr.b #2,d3 * mode, 0: ea -> Dn, 1: Dn -> ea
bra op_m4
op_m3 moveq #2,d3 * mode ea -> An
move.b #'A',(a3)+
op_m4 bsr do_size * .B, .W or .L
ea_Rn bsr reg_9_11 * adr or data register no
cmpi.b #1,d3
beq Dn_ea
move.w d7,-(sp) * save register no
move.w d3,-(sp) * save mode
bsr ea_0_5
move.w (sp)+,d3 * restore mode
move.w (sp)+,d7 * restore register no
move.b #comma,(a3)+
tst.b d3
beq data_reg * ea -> Dn
bra adr_reg * ea -> An
Dn_ea bsr data_reg * Dn -> ea
move.b #comma,(a3)+
bra ea_0_5
*------------------------------------------------------------------------------*
val8_16: * used in Bcc, DBcc, addq, subq
* value (in low byte of the op-code
clr.l d6 * or in the next word) to d6
move.b 1(a5),d6
ext.w d6
bne v8_16ex * if non_zero, displacement is 8 bits
move.w (a4)+,d6 * else disp is 16 bits in next word
v8_16ex ext.l d6
rts
*------------------------------------------------------------------------------*
sz_ea: * used in clr, neg, negx, tst
bsr copy_s * copy keyword
move.b 1(a5),d4
lsr.b #6,d4 * size
bsr do_size
bsr ea_0_5 * do ea
bra term
*------------------------------------------------------------------------------*
*----------------------------- do keyword -------------------------------------*
*------------------------------------------------------------------------------*
_exg: * mnemo. for exc Rx,Ry
lea k_exg,a0
bsr copy_s * copy keyword
move.b #tab,(a3)+
move.b 1(a5),d3
lsr.b #3,d3 * mode
move.b (a5),d7
lsr.b #1,d7 * Rx
cmpi.b #%01001,d3
bne _exg_Dx
bsr adr_reg * Rx is address register
bra _exg_Ry
_exg_Dx bsr data_reg * Rx is data register
_exg_Ry move.b #comma,(a3)+
move.b 1(a5),d7 * Ry
btst #0,d3
beq _exg_Dy
bsr adr_reg * Ry is address register
bra term
_exg_Dy bsr data_reg * Ry is data register
bra term
*------------------------------------------------------------------------------*
_and: * mnemo. for and
lea k_and,a0
bra op_md1 * go op-mode (in v1000)
*------------------------------------------------------------------------------*
_cmp: * mnemo. for cmp and cmpa
lea k_cmp,a0
bra op_md1 * go op-mode (in v1000)
*------------------------------------------------------------------------------*
_eor: * mnemo. eor
lea k_eor,a0
bra op_md1 * go op-mode (in v1000)
*------------------------------------------------------------------------------*
_bcd * sbcd, abcd
lea k_bcd,a0
bsr copy_s * copy keyword
move.b 1(a5),d2
lsr.b #3,d2 * 0: -> dy,dx 1: -> -(Ay),-(Ax)
bra RxRy * (no need size id: bit 1 clear)
*------------------------------------------------------------------------------*
div_mul: * mnemo. for divs, divu, muls, mulu
cmpi.b #%1000,d5
beq _div
lea k_mul,a0 * mul
bsr copy_s * copy keyword
bra u_s
_div lea k_div,a0 * div
bsr copy_s * copy keyword
u_s cmpi.b #%111,d3
bne is_u
move.b #'S',(a3)+ * ___s
bra do_dvml
is_u move.b #'U',(a3)+ * ___u
do_dvml move.b #tab,(a3)+
moveq #1,d4 * size operand is word
moveq #0,d3 * mode 1 (R=D) in ea_Rn (see op_mode)
bsr ea_Rn
bra term
*------------------------------------------------------------------------------*
_movep: * mnemo. for movep
lea str+mnemo,a3 * reset start ascii address
lea k_move,a0
bsr copy_s * copy keyword
move.b #'P',(a3)+
move.w (a5),d3
lsr.w #6,d3
andi.b #%011,d3
move.b d3,d4
andi.b #$001,d4
addq.b #1,d4 * size
bsr do_size
lsr.b #1,d3 * mode: 0: -> Dn, 1: -> d(An)
beq to_Dn
bsr reg_9_11 * mode 1: Dn -> d(Am)
bsr data_reg
move.b #comma,(a3)+
move.b 1(a5),d7 * address register (bit 0-2)
bsr indir_disp
bra term
to_Dn move.b 1(a5),d7 * mode 0: d(An) -> Dm
bsr indir_disp
move.b #comma,(a3)+
bsr reg_9_11
bsr data_reg
bra term
*------------------------------------------------------------------------------*
tstbit: * mnemo. for test bit familly
move.b #'B',(a3)+
move.w (a5),d1
lsr.w #6,d1
andi.b #%11,d1 * test only bit 6-7
bne tstb1
lea k_tst,a0
bsr copy_s * copy keyword
bra do_tstb
tstb1 cmpi.b #1,d1
bne tstb2
lea k_chg,a0
bsr copy_s * copy keyword
bra do_tstb
tstb2 cmpi.b #2,d1
bne tstb3
lea k_clr,a0
bsr copy_s * copy keyword
bra do_tstb
tstb3 cmpi.b #3,d1
bne unknown
lea k_set,a0
bsr copy_s * copy keyword
do_tstb move.b #tab,(a3)+
btst #0,(a5) * if set -> tested bit in Dn
bne tstbreg
moveq #0,d4 * size
bsr immediat * else tested is immediat value
bra tstb_ea
tstbreg move.w (a5),d1 * mode %001 is a special meanning
andi.w #%111000,d1
cmpi.w #%001000,d1
beq _movep
bsr reg_9_11 * take register no
bsr data_reg
tstb_ea bra com_ea * do ea
*------------------------------------------------------------------------------*
xxxi: * mnemo. for xxxi familly
tst.b d0
bne xxx1
lea k_or,a0
bra do_xxxi * ori
xxx1 cmpi.b #1,d0
bne xxx2
lea k_and,a0
bra do_xxxi * andi
xxx2 cmpi.b #2,d0
bne xxx3
lea k_sub,a0
bra do_xxxi * subi
xxx3 cmpi.b #3,d0
bne xxx5
lea k_add,a0
bra do_xxxi * addi
xxx5 cmpi.b #5,d0
bne xxx6
lea k_eor,a0
bra do_xxxi * eori
xxx6 cmpi.b #6,d0
bne unknown
lea k_cmp,a0 * cmpi
do_xxxi bsr copy_s * copy keyword
move.b #'I',(a3)+
move.b 1(a5),d3 * test for CCR or SR
move.b d3,d4
lsr.b #6,d4 * size
andi.b #%00111111,d3
cmpi.b #%00111100,d3 * ea for CCR or SR
beq s_cc_ri
bsr do_size
bsr immediat
bra com_ea * do ea
s_cc_ri move.b #tab,(a3)+ * to CCR or to SR
bsr immediat
move.b #comma,(a3)+
cmpi.b #1,d4
beq is_ccr
bsr do_CCR
bra term
is_ccr bsr do_SR
bra term
do_CCR lea k_ccr,a0
bra copy_s * copy keyword
do_SR lea k_sr,a0
bra copy_s * copy keyword
*------------------------------------------------------------------------------*
_move: * mnemo. for move
lea k_move,a0
bsr copy_s * copy keyword
move.w (a5),d3
lsr.w #6,d3
andi.w #%111,d3 * destination mode
cmpi.w #%001,d3 * move or movea ?
bne mv_sz
move.b #'A',(a3)+
mv_sz move.b d5,d4 * size
cmpi.b #2,d4
beq sz_move * .L
bgt w_move
moveq #0,d4 * .B
sz_move bsr do_size
move.w d3,-(sp) * save dest. mode
bsr ea_0_5 * source to ascii
move.b #comma,(a3)+
move.w (sp)+,d3 * restore dest. mode
move.b (a5),d7
lsr.b #1,d7 * destination register
andi.b #%111,d7
bsr do_md_rg * destination to ascii
bra term * exit
w_move moveq #1,d4 * .W
bra sz_move
*------------------------------------------------------------------------------*
_addq_subq: * mnemo. for addq, subq
clr.l d6
move.b (a5),d6
btst #0,d6 * 0: -> addq, 1: -> subq
bne _subq
lea k_add,a0
bra ___q
_subq lea k_sub,a0
___q bsr copy_s * copy keyword
move.b #'Q',(a3)+
bsr do_size
move.b #'#',(a3)+
lsr.b #1,d6
andi.b #%111,d6 * immediat value
bsr hx_$
bra com_ea * do ea
*------------------------------------------------------------------------------*
_scc: * mnemo. for Scc
move.b #'S',(a3)+
clr.w d0
move.b (a5),d0
andi.b #%1111,d0 * condition code
lea cc_code,a0 * other in cc_code table
lsl.b #1,d0 * multiply by 2
adda.w d0,a0
move.b (a0)+,(a3)+ * two char
move.b (a0)+,(a3)+
move.b #tab,(a3)+
bsr ea_0_5
bra term
*------------------------------------------------------------------------------*
_trap: * mnemo. for trap
lea k_trap,a0
bsr copy_s * copy keyword
move.b #tab,(a3)+
move.b #'#',(a3)+
clr.l d6
move.b 1(a5),d6
andi.b #%1111,d6 * vector no.
bsr hx_$
bra term
*------------------------------------------------------------------------------*
_jmp: * mnemo. for jmp
lea k_jmp,a0
bsr copy_s * copy keyword
bra tab_ea * ea
*------------------------------------------------------------------------------*
_jsr: * mnemo. for jsr
lea k_jsr,a0
bsr copy_s * copy keyword
bra tab_ea * ea
*------------------------------------------------------------------------------*
_unlk: * mnemo. for unlk
lea k_unlk,a0
bsr copy_s * copy keyword
move.b 1(a5),d7 * register no.
move.b #tab,(a3)+
bsr adr_reg * address register
bra term
*------------------------------------------------------------------------------*
_link: * mnemo. for link
lea k_link,a0
tab_An bsr copy_s * copy keyword
move.b 1(a5),d7 * register no.
move.b #tab,(a3)+
bsr adr_reg * address register
move.b #comma,(a3)+
moveq #1,d4 * size for immediat
bsr immediat
bra term
*------------------------------------------------------------------------------*
_illegal: * mnemo. for illegal
lea k_illg,a0
bsr copy_s * copy keyword
bra term
*------------------------------------------------------------------------------*
_tas: * mnemo. for tas
lea k_tas,a0
bsr copy_s * copy keyword
bra tab_ea * ea
*------------------------------------------------------------------------------*
_pea: * mnemo. for pea
lea k_pea,a0
bsr copy_s * copy keyword
bra tab_ea * ea
*------------------------------------------------------------------------------*
_swap: * mnemo. for swap
lea k_swap,a0
bsr copy_s * copy keyword
move.b 1(a5),d7 * register no.
move.b #tab,(a3)+
bsr data_reg * data register
bra term
*------------------------------------------------------------------------------*
_ext_movem: * mnemo. for ext or movem
move.b 1(a5),d0
move.b d0,d4
lsr.b #6,d4
subq.b #1,d4 * size
andi.b #%111111,d0 * ae
cmpi.b #%001000,d0
bcs _ext * ae = data register is for _ext only
*------------------------------------------------------------------------------*
_movem lea k_move,a0
bsr copy_s * copy keyword
move.b #'M',(a3)+
bsr do_size * .L or .W
move.w (a4)+,d2 * register mask
btst #2,(a5) * direction
bne _movem1
move.b 1(a5),d1 * type: movem d1-d5,-(a7)
andi.b #%111000,d1
cmpi.b #%100000,d1 * pre-decrement mode ?
bne _movem0 * yes, no need mask inversion
bsr inv_bit * bit 0 become bit 15, etc
move.w d1,d2
_movem0 bsr mask
bsr com_ea
bra term
_movem1 bsr ea_0_5 * type: movem (a7)+,d1-d5
move.b #comma,(a3)+
bsr mask
bra term
*------------------------------------------------------------------------------*
inv_bit: * inverse word d2 (mirror image) to d1
moveq #15,d0 * bit counter
do_inv lsr.w #1,d2 * test bit
bcs inv_1
bclr d0,d1 * clear the bit
dbra d0,do_inv
rts
inv_1 bset d0,d1 * set the bit
dbra d0,do_inv
rts
*------------------------------------------------------------------------------*
mask: * mnemo register mask in movem
moveq #-1,d3 * bit counter
clr.b d1 * not first time flag
mask0 addq.b #1,d3
cmpi.b #15,d3 * last bit ?
bhi mask_ex * yes, return
btst d3,d2 * bit is clear ?
beq mask0 * try next
tst.b d1 * now bit is set. first time ?
beq mask00 * yes, no need '/'
move.b #'/',(a3)+ * separator
mask00 bsr mask_Rn * print start sequence register
bsr mask1 * what's fellow ?
bra mask0
mask1 st d1 * not first time
addq.b #1,d3 * next bit
cmpi.b #15,d3 * last bit ?
bhi mask_ex * yes, return
btst d3,d2 * bit is clear ?
beq mask_ex * yes, only one in sequense, return
move.b #'-',(a3)+ * else, '-' separator.
mask_2 btst d3,d2 * 1 again ?
beq maskend * no, exit loop
cmpi.b #15,d3 * last bit ?
beq mask_Rn * yes, print register and return
addq.b #1,d3 * yes, try next bit
bra mask_2
maskend subq.b #1,d3 * no of last bit set
bra mask_Rn * print end of sequence register
mask_ex rts
*------------------------------------------------------------------------------*
mask_Rn: * print one of d0-d7,a0-a7 (d0=0-15)
move.b d3,d7
andi.b #7,d7 * register no
cmpi.b #8,d3 * adr or data register
bcs data_reg
bcc adr_reg
*------------------------------------------------------------------------------*
_ext lea k_ext,a0
bsr copy_s * copy keyword
bsr do_size
move.b 1(a5),d7 * register no.
bsr data_reg * data register
bra term
*------------------------------------------------------------------------------*
_nbcd: * mnemo. for nbcd
move.b #'N',(a3)+
lea k_bcd,a0
bsr copy_s * copy keyword
bra tab_ea * ea
*------------------------------------------------------------------------------*
mv_CCR: * move ea,CCR
bsr do_mv
moveq #1,d4 * word size
bsr ea_0_5 * ea
move.b #comma,(a3)+
bsr do_CCR * (in xxxi)
bra term
do_mv lea k_move,a0
bsr copy_s * copy keyword
move.b #tab,(a3)+
rts
*------------------------------------------------------------------------------*
mv_USP: * move USP,An or move An,USP
bsr do_mv * (in mv_CCR)
move.b 1(a5),d7 * register no.
btst #3,d7 * bit 3 of opcode
beq An_USP * 0: -> An,USP
bsr do_USP * 1: -> USP,An
move.b #comma,(a3)+
bsr adr_reg * address register
bra term
An_USP bsr adr_reg * address register
move.b #comma,(a3)+
bsr do_USP
bra term
do_USP lea k_usp,a0
bsr copy_s
rts
*------------------------------------------------------------------------------*
mv_f_SR: * move SR,ea
bsr do_mv * (in mv_CCR)
bsr do_SR
move.b #comma,(a3)+
bsr ea_0_5 * ea
bra term
*------------------------------------------------------------------------------*
mv_t_SR: * move ea,SR
bsr do_mv * (in mv_CCR)
moveq #1,d4 * word size
bsr ea_0_5 * ea
move.b #comma,(a3)+
bsr do_SR
bra term
*------------------------------------------------------------------------------*
_chk_lea: * mnemo. for chk or lea
btst #6,1(a5) * 1 -> lea 0 -> chk
beq _chk
lea k_lea,a0
moveq #2,d3 * type: ea,An
bra do_chk
_chk lea k_chk,a0
moveq #0,d3 * type: ea,Dn
do_chk bsr copy_s * copy keyword
move.b #tab,(a3)+
bsr ea_Rn * (in op_mode)
bra term
*------------------------------------------------------------------------------*
_clr: * mnemo. for clr
lea k_clr,a0
bra sz_ea
*------------------------------------------------------------------------------*
_neg: * mnemo. for neg
lea k_neg,a0
bra sz_ea
*------------------------------------------------------------------------------*
_negx: * mnemo. for negx
lea k_negx,a0
bra sz_ea
*------------------------------------------------------------------------------*
_not: * mnemo. for not
lea k_not,a0
bra sz_ea
*------------------------------------------------------------------------------*
_tst: * mnemo. for tst
lea k_tst,a0
bra sz_ea
*------------------------------------------------------------------------------*
*----------------------------- data and space ---------------------------------*
*------------------------------------------------------------------------------*
.data
mode_tb .dc.l data_reg * mode = %000
.dc.l adr_reg * mode = %001
.dc.l indirect * mode = %010
.dc.l post_inc * mode = %011
.dc.l pre_dec * mode = %100
.dc.l indir_disp * mode = %101
.dc.l index_disp * mode = %110
.dc.l mode7 * mode = %111
md7_tb .dc.l abs_w * reg = %000
.dc.l abs_l * reg = %001
.dc.l pc_disp * reg = %010
.dc.l pc_index * reg = %011
.dc.l immediat * reg = %100
.dc.l unknown * reg = %101
.dc.l unknown * reg = %110
.dc.l unknown * reg = %111
k_add .dc.b "ADD",0 * mnemotechnic keyword
k_and .dc.b "AND",0
k_bcd .dc.b "BCD",0
k_chg .dc.b "CHG",0
k_chk .dc.b "CHK",0
k_clr .dc.b "CLR",0
k_cmp .dc.b "CMP",0
k_div .dc.b "DIV",0
k_eor .dc.b "EOR",0
k_exg .dc.b "EXG",0
k_ext .dc.b "EXT",0
k_illg .dc.b "ILLEGAL",0
k_jmp .dc.b "JMP",0
k_jsr .dc.b "JSR",0
k_lea .dc.b "LEA",0
k_link .dc.b "LINK",0
k_move .dc.b "MOVE",0
k_mul .dc.b "MUL",0
k_neg .dc.b "NEG",0
k_negx .dc.b "NEGX",0
k_nop .dc.b "NOP",0
k_not .dc.b "NOT",0
k_or .dc.b "OR",0
k_pea .dc.b "PEA",0
k_reset .dc.b "RESET",0
k_rte .dc.b "RTE",0
k_rtr .dc.b "RTR",0
k_rts .dc.b "RTS",0
k_stop .dc.b "STOP",0
k_set .dc.b "SET",0
k_sub .dc.b "SUB",0
k_swap .dc.b "SWAP",0
k_tas .dc.b "TAS",0
k_trap .dc.b "TRAP",0
k_trapv .dc.b "TRAPV",0
k_tst .dc.b "TST",0
k_unlk .dc.b "UNLK",0
k_ccr .dc.b "CCR",0
k_sr .dc.b "SR",0
k_usp .dc.b "USP",0
cc_code .dc.b "T F HILSCCCSNEEQVCVSPLMIGELTGTLE"
over_s .dc.b 13,10,"Walkback over stack",0
intro_s .dc.b 13,10,27,'v',27,'p'," ***** MONITOR, by Alain Birtz ****** "
.dc.b 27,'q',0
main_s .dc.b 13,10,"Disasm Trace Hexed Search Free"
.dc.b " Move Load Break Go Regs CCR Info Exit: ",0
bye_s .dc.b 13,10,"Byebye",0
adr_1st .dc.b 13,27,'K',"start address: ",0
src_s .dc.b 13,27,'K',"SOURCE",10,0
dest_s .dc.b 13,27,'K',"DESTINATION",10,0
adr_end .dc.b 27,'C',27,'C',27,'C',27,'C',27,'C',27,'C'," end address: ",0
free_s .dc.b 13,27,'K',"bytes free: need: ",0
in_s .dc.b 13,27,'K',"input-> Memory, Prg file, Data file, Exit: ",0
out_s .dc.b 13,27,'K',"output-> Screen, Printer, File, Exit: ",0
s_move .dc.b 13,27,'K',"1- file to memory 2- memory to file "
.dc.b " 3- memory to memory 0- exit: ",0
name_s .dc.b 13,27,'K',"pathname: ",0
io_er_s .dc.b 13,10,"I/O error no $____",0
altd_s .dc.b 13,27,'K',"Do you want save altered file (N,Y): ",0
c_p_a_s .dc.b " Current prg. adr: ________",0
from_s .dc.b 13,10,27,'p'," From $________ to $________ ",27,'q',10,0
b_pg_s .dc.b 13,10,27,'p'," text $________-$________ data $________"
.dc.b "-$________ bss $________-$________ ",27,'q',10,0
s_CCR .dc.b 13,10," ________ status: _____ ",0
codeCCR .dc.b "XNZVC"
newCCRs .dc.b 13,27,'K',"New CCR value [$0-$1f]: ",0
data_s .dc.b 13,27,'K',"DATA file: ",0
prg_s .dc.b 13,"PRG file: ",0
break_s .dc.b 13,27,'K',"break point address: ",0
brkno_s .dc.b 13,27,'K',"how many time: ",0
srch_s .dc.b 13,27,'K',"search Ascii string, Byte "
.dc.b "hexa string , Exit: ",0
ascii_s .dc.b 13,27,'K',"ascii string: ",0
byte_s .dc.b 13,27,'K',"hexa byte string: ",0
found_s .dc.b 13,10,"found at memory adr. $",0
fileoff .dc.b 13,10,"found at file offset $",0
notfind .dc.b 13,10,"not found",0
s_at .dc.b " at: ",0
pause_s .dc.b 13,10,"pause",0
cont_s .dc.b 13,27,'K',"continue",0
work_s .dc.b 13,10,"working...",0
trcnt_s .dc.b 13,27,'K',"traced ________ instruction",0
excep_s .dc.b 13,10,">>>>> traced exception <<<<< ",0
s_bus .dc.b "Bus error",0
s_adr .dc.b "Address error",0
s_illeg .dc.b "Illegal intruction",0
c_s .dc.b 27,'j',0 * save cursor pos
c_r .dc.b 27,'k',0 * restore cursor pos
r_on_s .dc.b 27,'p',0 * reverse on string
r_off_s .dc.b 27,'q',0 * reverse off string
n_line .dc.b 13,10,0
up_ln .dc.b 27,'I',13,0 * cursor up + CR (with scrool)
up_s .dc.b 27,'A',0 * cursor up
down_s .dc.b 27,'B',0 * cursor down
left_s .dc.b 27,'D',0 * cursor left
right_s .dc.b 27,'C',0 * cursor up
R_s .dc.b 27,'j',27,'A',13,27,'C',27,'C',0
R_ex_s .dc.b 27,'k',27,'q',0 * in sel_R routine
R_chr_s .dc.b '0',27,'D',0
cur_fg .dc.w -1 * cursor position flag
.even
exepnew .dc.l v_bus, v_adr, v_illeg
base_pg .dc.l 0 * base page address
*------------------------------------------------------------------------------*
.bss
.even
ipname .ds.b 74 * pathname + command tail (prg)
tail .ds.b 72 * command tail only
idname .ds.b 74 * input pathname (data)
odname .ds.b 74 * output pathname (data)
temp_s .ds.b 8 * temporary storage
str .ds.b 240 * work space
mv_str .ds.b 159 * move space
outdev .ds.b 1 * output device id
indev .ds.b 1 * input device id
op_main .ds.b 1 * main option
altd_fg .ds.b 1 * altered flag
wr_fg .ds.b 0 * write mem flag
srch_fg .ds.b 1 * found something: 1, else: 0
wildstr .ds.b 20 * wildcard string
srchstr .ds.b 23 * search string
nil_val .ds.b 1 * no value read flag
wait_fg .ds.b 1 * pause flag
sp_up .ds.b 1 * stack up flag
sp_dn .ds.b 1 * stack down flag
sp_eq .ds.b 1 * stack equal flag
.even
srchreg .ds.l 6 * register save for search
svtrap8 .ds.l 1 * save trap 8 vector
brkcode .ds.w 1 * code replaced by trap #8
brkadr .ds.l 1 * break point address
brkno .ds.l 1 * no of the breakpoint
exepold .ds.l 3 * save old exception vector
saveCCR .ds.w 1 * CCR saved...
ihandle .ds.w 1 * input file handle
ohandle .ds.w 1 * output file handle
dta .ds.l 1 * disk transfert address
sv_ssp .ds.l 1 * supervisor save area
save1st .ds.l 1 * start address
saveend .ds.l 1 * end address
regs .ds.l 16 * register save
cur_adr .ds.l 1 * current address
sp_1st .ds.l 1 * stack pointer reference
trcount .ds.l 1 * instruction counter
mon_sp .ds.l 1 * monitor stack pointer
prg_sp .ds.l 1 * program stack pointer
.ds.l 400
prg_stk .ds.l 1 * program stack
.ds.l 100
mon_stk .ds.l 1 * monitor stack
.end
əəəəəəəəəəəəəə